import type * as interfaces from './interfaces.js'; import { FfmpegCommand, type TFfmpegInput, type IInputOptions } from './classes.ffmpegcommand.js'; /** * Event callback types */ export type TProgressCallback = (progress: interfaces.IProgressInfo) => void; export type TErrorCallback = (error: Error) => void; export type TEndCallback = () => void; /** * SmartFfmpeg - A fast Node.js module for media file conversion using ffmpeg * * @example Modern Builder API * ```typescript * const ffmpeg = new SmartFfmpeg(); * * // File to file with fluent API * await ffmpeg.create() * .input('/path/to/input.mp4') * .videoCodec('libx264') * .audioBitrate('128k') * .size(1920, 1080) * .output('/path/to/output.mp4') * .run(); * * // Buffer to buffer * const outputBuffer = await ffmpeg.create() * .input(inputBuffer, { format: 'mp4' }) * .videoCodec('libx264') * .toBuffer('webm'); * * // With progress tracking * await ffmpeg.create() * .input('/path/to/input.mp4') * .videoCodec('libx264') * .onProgress(p => console.log(`${p.percent?.toFixed(1)}%`)) * .output('/path/to/output.mp4') * .run(); * * // Stream output * const stream = ffmpeg.create() * .input('/path/to/input.mp4') * .videoCodec('libx264') * .toStream('mp4'); * ``` * * @example Legacy API (still supported) * ```typescript * await ffmpeg.convert('input.mp4', 'output.webm', { * videoCodec: 'libvpx-vp9', * audioBitrate: '128k' * }); * ``` */ export declare class SmartFfmpeg { private ffmpegPath; private ffprobePath; constructor(); /** * Create a new FfmpegCommand builder for fluent API usage * * @example * ```typescript * await ffmpeg.create() * .input('/path/to/input.mp4') * .videoCodec('libx264') * .crf(23) * .output('/path/to/output.mp4') * .run(); * ``` */ create(): FfmpegCommand; /** * Shorthand to create a command with input already set * * @example * ```typescript * // File input * await ffmpeg.input('/path/to/input.mp4') * .videoCodec('libx264') * .output('/path/to/output.mp4') * .run(); * * // Buffer input * const output = await ffmpeg.input(buffer, { format: 'mp4' }) * .videoCodec('libx264') * .toBuffer('webm'); * ``` */ input(source: TFfmpegInput, options?: IInputOptions): FfmpegCommand; /** * Get media file information using ffprobe */ getMediaInfo(inputPath: string): Promise; /** * Convert media file with specified options */ convert(inputPath: string, outputPath: string, options?: interfaces.IConversionOptions): Promise; /** * Convert media file with progress reporting */ convertWithProgress(inputPath: string, outputPath: string, options?: interfaces.IConversionOptions, onProgress?: TProgressCallback): Promise; /** * Extract audio from video file */ extractAudio(inputPath: string, outputPath: string, options?: Pick): Promise; /** * Remove audio from video file */ removeAudio(inputPath: string, outputPath: string, options?: Pick): Promise; /** * Take a screenshot at a specific time */ screenshot(inputPath: string, outputPath: string, options: interfaces.IScreenshotOptions): Promise; /** * Generate multiple thumbnails from video */ generateThumbnails(inputPath: string, outputDir: string, options: interfaces.IThumbnailOptions): Promise; /** * Resize video */ resize(inputPath: string, outputPath: string, width?: number, height?: number, options?: Omit): Promise; /** * Change video frame rate */ changeFrameRate(inputPath: string, outputPath: string, fps: number, options?: Omit): Promise; /** * Trim media file */ trim(inputPath: string, outputPath: string, startTime: number | string, duration: number | string, options?: Omit): Promise; /** * Convert to GIF */ toGif(inputPath: string, outputPath: string, options?: { width?: number; height?: number; fps?: number; startTime?: number | string; duration?: number | string; }): Promise; /** * Concatenate multiple media files */ concat(inputPaths: string[], outputPath: string, options?: interfaces.IConversionOptions): Promise; /** * Add audio to video */ addAudio(videoPath: string, audioPath: string, outputPath: string, options?: { videoCodec?: interfaces.TVideoCodec; audioCodec?: interfaces.TAudioCodec; audioBitrate?: string; shortest?: boolean; overwrite?: boolean; }): Promise; /** * Get available encoders */ getEncoders(): Promise; /** * Get available decoders */ getDecoders(): Promise; /** * Get available formats */ getFormats(): Promise; /** * Run ffmpeg with raw arguments */ runRaw(args: string[]): Promise<{ stdout: string; stderr: string; }>; /** * Run ffprobe with raw arguments */ runProbeRaw(args: string[]): Promise<{ stdout: string; stderr: string; }>; private buildConversionArgs; private buildScaleFilter; private formatTime; private parseStreamInfo; private runProcess; }