/** * @fileoverview Probes the intrinsic dimensions of a video stream by parsing * its container header. It never decodes a frame, so it works for codecs the * browser cannot play. * * Supported containers: ISO base media (MP4, MOV, M4V, 3GP), Matroska/WebM, * AVI, AMV, Ogg/Theora, MPEG-1/2 elementary streams, MPEG program streams * (VOB), MPEG transport streams (TS, MTS, M2TS), FLV, ASF/WMV, RealMedia, * NSV and RoQ. * * Note on production usage for MP4: Ensure your videos are optimized for web streaming * (e.g., encoded with ffmpeg `-movflags faststart`). This places the `moov` atom at the * beginning of the file, allowing the probe to resolve dimensions within the first few kilobytes * instead of requiring the entire file to be loaded into memory. */ import TinyBufferReader from '../../utils/TinyBufferReader.mjs'; export type MediaProbeSize = { /** * - The display width in pixels. */ width: number; /** * - The display height in pixels. */ height: number; }; export type MediaFormat = { /** * - The container identifier. */ name: string; /** * - A function that tests if the provided bytes match the container's signature. */ sniff: (bytes: Uint8Array) => boolean; /** * - A function that parses the container to extract the media dimensions. */ parse: (reader: TinyBufferReader) => MediaProbeSize | null; }; /** * Reads the intrinsic dimensions of a video stream from its container header. * @beta */ declare class TinyMediaProbe { #private; /** * @param {string} [type] - The MIME type from the response headers. Unused, kept for API compatibility. * @param {number} [maxBytes] - The maximum number of header bytes to buffer. * @throws {RangeError} If `maxBytes` is not a positive number. */ constructor(type?: string, maxBytes?: number); /** * Appends a chunk and returns the dimensions once they are known. * @param {Uint8Array} chunk - The bytes received so far. * @returns {MediaProbeSize|null} The dimensions, or null when more data is needed. * @throws {TypeError} If `chunk` is not a Uint8Array. */ push(chunk: Uint8Array): MediaProbeSize | null; /** * Releases the buffered header. * @returns {void} */ close(): void; } export default TinyMediaProbe; //# sourceMappingURL=TinyMediaProbe.d.mts.map