UNPKG

ffmpeg-toolkit

Version:

A modern FFmpeg toolkit for Node.js

110 lines 3.25 kB
import { EventEmitter } from 'events'; import ffmpeg from 'fluent-ffmpeg'; import { BaseResponse, CoreConfig, CoreState, FFmpegOptions, Platform, ProcessOptions, Status, VideoInfo } from '../types/index.js'; import { LoggerService } from '../utils/index.js'; /** * Base class for FFmpeg operations * Handles core video processing functionality */ export declare class BaseCore extends EventEmitter { readonly ffmpeg: typeof ffmpeg; private rootOutput; protected pathOutputForder: string; protected config: CoreConfig; protected state: CoreState; protected logger: LoggerService | null; private static readonly VIDEO_CONSTANTS; protected defaultOptions: FFmpegOptions; constructor(config?: CoreConfig); /** * Initialize core configuration */ private initializeConfig; /** * Initialize FFmpeg settings and directories */ private initializeFFmpeg; /** * Initialize logger if enabled */ private initializeLogger; /** * Handle errors in a consistent way across all classes */ protected handleError(error: unknown, context: string): never; /** * Public method to handle errors from outside the class */ handleModuleError(error: unknown, context: string): never; /** * Get video information using ffprobe */ protected getVideoInfo(videoPath: string): Promise<ffmpeg.FfprobeStream>; /** * Get platform-specific video filter */ protected getPlatformVideoFilter(platform: Platform, videoInfo: ffmpeg.FfprobeStream): string; /** * Calculate target dimensions based on aspect ratio */ private calculateTargetDimensions; /** * Calculate optimal bitrate for video */ private calculateBitrate; /** * Get optimized FFmpeg options for video */ protected getOptimizedOptions(videoInfo: VideoInfo): FFmpegOptions; /** * Get FFmpeg options */ protected getFFmpegOptions(customOptions?: FFmpegOptions): string[]; /** * Get input options */ protected getInputOptions(customOptions?: FFmpegOptions): string[]; /** * Set default FFmpeg options */ setDefaultOptions(options: Partial<FFmpegOptions>): void; /** * Create response object */ response<T>({ status, message, data }: BaseResponse<T>): BaseResponse<T>; /** * Process video with FFmpeg */ process<T, K, E>(options: ProcessOptions<T, K, E>): Promise<BaseResponse<T>>; /** * Setup FFmpeg command options */ private setupCommandOptions; /** * Setup platform-specific options */ private setupPlatformOptions; /** * Setup FFmpeg command event handlers */ private setupCommandHandlers; /** * Clean up resources */ destroy(): void; /** * Get default FPS */ getDefaultFps(): number; /** * Update core state */ protected updateState(status: Status, error?: Error, progress?: number): void; /** * Get current core state */ getState(): CoreState; getOutputFolder(): string; getVideoInfoPublic(videoPath: string): Promise<ffmpeg.FfprobeStream>; } //# sourceMappingURL=BaseCore.d.ts.map