sheng-tool
    Preparing search index...

    Function detectMediaFileFormat

    • 先按图片格式、再按视频格式识别媒体文件类型。

      Parameters

      • bytes: ByteSource

        待检查的字节序列,可以是 Uint8Array、Buffer 或普通数字数组。

      Returns "gif" | "png" | "jpeg" | "webp" | "avif" | "bmp" | "ico" | "mp4" | "webm" | null

      识别到的媒体格式;无法识别时返回 null。

      0.2.0

      detectMediaFileFormat(new Uint8Array([71, 73, 70, 56, 57, 97]))        // 'gif'
      detectMediaFileFormat(new Uint8Array([0x1a, 0x45, 0xdf, 0xa3])) // 'webm'