use-ffmpeg
Version:
A React hook for browser-based media processing using FFmpeg WASM - handles video and other file formats conversion with ease
21 lines • 1.26 kB
TypeScript
import type { FFmpeg } from "@ffmpeg/ffmpeg";
/**
* Transcodes a file using FFmpeg and returns the output as a downloadable URL and its human-readable size.
*
* This function handles the file conversion process using FFmpeg, including writing the file to FFmpeg's virtual file system,
* executing the FFmpeg command, and cleaning up temporary files after the conversion.
*
* @param {FFmpeg | null} ffmpeg - The initialized FFmpeg instance.
* @param {File} file - The input file to be transcoded.
* @param {string} outputFileFullName - The name of the output file, including its extension.
* @param {string[]} [cmdOptions] - Optional array of additional FFmpeg command-line options.
* @returns {Promise<{ url: string; fileSize: string }>} A promise resolving to an object containing:
* - `url` (string): A downloadable URL for the transcoded file.
* - `fileSize` (string): The size of the transcoded file in a human-readable format.
* @throws {Error} If FFmpeg is not loaded, or if any error occurs during the transcoding process.
*/
export declare const transcode: (ffmpeg: FFmpeg | null, file: File, outputFileFullName: string, cmdOptions?: string[]) => Promise<{
url: string;
fileSize: string;
}>;
//# sourceMappingURL=transcode.d.ts.map