import { AudioDemuxerPacket, DemuxerPacket, FFFSMountOptions, FFFSPath, FFFSType, FFMessageFrameData, FFMessageLoadConfig, FFMessageRenderSettings, FileData, FSNode, IsFirst, LogEventCallback, OK, ProgressEventCallback, FFMessageMuxerData, FFMessageInitMuxerData, FFMessageAuthentificateData, FFMessageFetchTSChunksData, FFMessageTranscodeData, FFMessageFrame, FFMessageChunkedMuxData } from "./types"; import { MediaInfo } from '../../modules/ffmpeg/types/FFmpeg.types'; import { HashAlgorithmEnum } from '../../types/hash.types'; type FFMessageOptions = { signal?: AbortSignal; }; /** * Provides APIs to interact with ffmpeg web worker. * * @example * ```ts * const ffmpeg = new FFmpeg(); * ``` */ export declare class FFmpeg { #private; loaded: boolean; /** * Listen to log or prgress events from `ffmpeg.exec()`. * * @example * ```ts * ffmpeg.on("log", ({ type, message }) => { * // ... * }) * ``` * * @example * ```ts * ffmpeg.on("progress", ({ progress, time }) => { * // ... * }) * ``` * * @remarks * - log includes output to stdout and stderr. * - The progress events are accurate only when the length of * input and output video/audio file are the same. * * @category FFmpeg */ on(event: "log", callback: LogEventCallback): void; on(event: "progress", callback: ProgressEventCallback): void; /** * Unlisten to log or prgress events from `ffmpeg.exec()`. * * @category FFmpeg */ off(event: "log", callback: LogEventCallback): void; off(event: "progress", callback: ProgressEventCallback): void; /** * Loads ffmpeg-core inside web worker. It is required to call this method first * as it initializes WebAssembly and other essential variables. * * @category FFmpeg * @returns `true` if ffmpeg core is loaded for the first time. */ load: (config: FFMessageLoadConfig, { signal }?: FFMessageOptions) => Promise; /** * Execute ffmpeg command. * * @remarks * To avoid common I/O issues, ["-nostdin", "-y"] are prepended to the args * by default. * * @example * ```ts * const ffmpeg = new FFmpeg(); * await ffmpeg.load(); * await ffmpeg.writeFile("video.avi", ...); * // ffmpeg -i video.avi video.mp4 * await ffmpeg.exec(["-i", "video.avi", "video.mp4"]); * const data = ffmpeg.readFile("video.mp4"); * ``` * * @returns `0` if no error, `!= 0` if timeout (1) or error. * @category FFmpeg */ exec: ( /** ffmpeg command line args */ args: string[], /** * milliseconds to wait before stopping the command execution. * * @defaultValue -1 */ timeout?: number, { signal }?: FFMessageOptions) => Promise; /** * Terminate all ongoing API calls and terminate web worker. * `FFmpeg.load()` must be called again before calling any other APIs. * * @category FFmpeg */ terminate: () => void; /** * Write data to ffmpeg.wasm. * * @example * ```ts * const ffmpeg = new FFmpeg(); * await ffmpeg.load(); * await ffmpeg.writeFile("video.avi", await fetchFile("../video.avi")); * await ffmpeg.writeFile("text.txt", "hello world"); * ``` * * @category File System */ writeFile: (path: string, data: FileData, { signal }?: FFMessageOptions) => Promise; mount: (fsType: FFFSType, options: FFFSMountOptions, mountPoint: FFFSPath) => Promise; unmount: (mountPoint: FFFSPath) => Promise; fileExists: (path: string, { signal }?: FFMessageOptions) => Promise; dirExists: (path: string, { signal }?: FFMessageOptions) => Promise; /** * Read data from ffmpeg.wasm. * * @example * ```ts * const ffmpeg = new FFmpeg(); * await ffmpeg.load(); * const data = await ffmpeg.readFile("video.mp4"); * ``` * * @category File System */ readFile: (path: string, /** * File content encoding, supports two encodings: * - utf8: read file as text file, return data in string type. * - binary: read file as binary file, return data in Uint8Array type. * * @defaultValue binary */ encoding?: string, { signal }?: FFMessageOptions) => Promise; readFilesAsBlob: (paths: string[], mimeType?: string, { signal }?: FFMessageOptions) => Promise; /** * Delete a file. * * @category File System */ deleteFile: (path: string, { signal }?: FFMessageOptions) => Promise; /** * Rename a file or directory. * * @category File System */ rename: (oldPath: string, newPath: string, { signal }?: FFMessageOptions) => Promise; /** * Create a directory. * * @category File System */ createDir: (path: string, { signal }?: FFMessageOptions) => Promise; /** * List directory contents. * * @category File System */ listDir: (path: string, { signal }?: FFMessageOptions) => Promise; /** * Delete an empty directory. * * @category File System */ deleteDir: (path: string, { signal }?: FFMessageOptions) => Promise; getBuildInfo: () => Promise; prepareRenderer: (settings: FFMessageRenderSettings, { signal }?: FFMessageOptions) => Promise; addFrameDataToRenderer: ({ data }: FFMessageFrameData, { signal }?: FFMessageOptions) => Promise; addFrameToRenderer: ({ frame }: FFMessageFrame, { signal }?: FFMessageOptions) => Promise; cancelRenderer: ({ signal }?: FFMessageOptions) => Promise; finalizeRenderer: ({ signal }?: FFMessageOptions) => Promise; muxChunkedOutput: (data: FFMessageChunkedMuxData, { signal }?: FFMessageOptions) => Promise; initDemuxer: (id: string, path: string, { signal }?: FFMessageOptions) => Promise; closeDemuxer: (id: string, { signal }?: FFMessageOptions) => Promise; seekDemuxer: (id: string, time: number, { signal }?: FFMessageOptions) => Promise; getNextPacketDemuxer: (id: string, { signal }?: FFMessageOptions) => Promise; initAudioDemuxer: (id: string, path: string, audioStream?: number, { signal }?: FFMessageOptions) => Promise; closeAudioDemuxer: (id: string, { signal }?: FFMessageOptions) => Promise; seekAudioDemuxer: (id: string, time: number, { signal }?: FFMessageOptions) => Promise; getNextPacketAudioDemuxer: (id: string, { signal }?: FFMessageOptions) => Promise; initMuxer: (initSettings: FFMessageInitMuxerData, { signal }?: FFMessageOptions) => Promise; addChunkMuxer: (data: FFMessageMuxerData, { signal }?: FFMessageOptions) => Promise; closeMuxer: ({ signal }?: FFMessageOptions) => Promise; transcode: (data: FFMessageTranscodeData, { signal }?: FFMessageOptions) => Promise; authentificate: (data: FFMessageAuthentificateData, { signal }?: FFMessageOptions) => Promise; isAuthenticated: () => Promise; getAuthStatus: () => Promise; getAuthSecondsRemaining: () => Promise; getAuthLicenseType: () => Promise; fetchFSChunks: (data: FFMessageFetchTSChunksData, { signal }?: FFMessageOptions) => Promise; getSettings: () => Promise; /** * Gets information about a media file. * * @example * ```ts * const ffmpeg = new FFmpeg(); * await ffmpeg.load(); * await ffmpeg.writeFile("video.avi", ...); * const info = await ffmpeg.getMediaInfo("video.mp4"); * ``` * * @returns an object with the following properties: * - status: 'success' | 'error' (in case of error another property will be present 'error' with the error string) * - path: the path of the media file * - duration: the duration in seconds * - format: the format of the media file * - averageFps: the average fps of all the video streams * - streamCount: the number of streams * - streams: an array of objects with the following properties: * - index: the index of the stream * - codec: the codec of the stream * - type: 'video' | 'audio' | 'image' | 'gif' | 'subtitle' | 'data' | 'attachment' | 'unknown' * - format: the format of the stream * - duration: the duration in seconds * - bitrate: the bitrate in bits per second * - startTime: the start time in seconds * In case of videos: * - width: the width of the video * - height: the height of the video * - rotation: the rotation of the video * - averageFps: the average fps of the video * - frameCount: the number of frames in the video * In case of audio: * - sampleRate: the sample rate of the audio * - channelCount: the number of channels in the audio * @category FFmpeg */ getMediaInfo: (path: string, { signal }?: FFMessageOptions) => Promise; getFileHash: (path: string, algorithm: HashAlgorithmEnum, { signal }?: FFMessageOptions) => Promise; getMediaSubtitles: (path: string, { signal }?: FFMessageOptions) => Promise; private tmpADownloadTag; downloadFile: (path: string, downloadFileName: string | undefined) => Promise; createArchive: (path: string, { signal }?: FFMessageOptions) => Promise; openArchive: (path: string, { signal }?: FFMessageOptions) => Promise; closeArchive: (id: number, { signal }?: FFMessageOptions) => Promise; addFileToArchive: (id: number, path: string, targetDirectory: string, { signal }?: FFMessageOptions) => Promise; addFilesToArchive: (id: number, paths: string[], targetDirectory: string, { signal }?: FFMessageOptions) => Promise; saveArchive: (id: number, { signal }?: FFMessageOptions) => Promise; listFilesFromArchive: (id: number, { signal }?: FFMessageOptions) => Promise; extractFileFromArchive: (id: number, fromPath: string, toPath: string, { signal }?: FFMessageOptions) => Promise; extractAllFromArchive: (id: number, path: string, { signal }?: FFMessageOptions) => Promise; addDataToArchive: (id: number, path: string, data: Uint8Array, { signal }?: FFMessageOptions) => Promise; readFileFromArchive: (id: number, path: string, { signal }?: FFMessageOptions) => Promise; } export {};