diff --git a/src/common/ffmpeg-addon.ts b/src/common/ffmpeg-addon.ts new file mode 100644 index 00000000..1712e510 --- /dev/null +++ b/src/common/ffmpeg-addon.ts @@ -0,0 +1,71 @@ +/** + * FFmpeg Node.js Native Addon Type Definitions + * + * This addon provides FFmpeg functionality for Node.js including: + * - Video information extraction with thumbnail generation + * - Audio/Video duration detection + * - Audio format conversion to NTSILK + * - Audio decoding to PCM + */ + +/** + * Video information result object + */ +export interface VideoInfo { + /** Video width in pixels */ + width: number; + + /** Video height in pixels */ + height: number; + + /** Video duration in seconds */ + duration: number; + + /** Container format name (e.g., "mp4", "mkv", "avi") */ + format: string; + + /** Video codec name (e.g., "h264", "hevc", "vp9") */ + videoCodec: string; + + /** First frame thumbnail as BMP image buffer */ + image: Buffer; +} + +/** + * Audio PCM decoding result object + */ +export interface AudioPCMResult { + /** PCM audio data as 16-bit signed integer samples */ + pcm: Buffer; + + /** Sample rate in Hz (e.g., 44100, 48000, 24000) */ + sampleRate: number; + + /** Number of audio channels (1 for mono, 2 for stereo) */ + channels: number; +} + +/** + * FFmpeg interface providing all audio/video processing methods + */ +export interface FFmpeg { + /** + * Get video information including resolution, duration, format, codec and first frame thumbnail + */ + getVideoInfo(filePath: string, format?: 'bmp' | 'bmp24'): Promise; + + /** + * Get duration of audio or video file in seconds + */ + getDuration(filePath: string): Promise; + + /** + * Convert audio file to NTSILK format (WeChat voice message format) + */ + convertToNTSilkTct(inputPath: string, outputPath: string): Promise; + + /** + * Decode audio file to raw PCM data + */ + decodeAudioToPCM(filePath: string): Promise; +} \ No newline at end of file diff --git a/src/native/ffmpeg/ffmpegAddon.darwin.arm64.node b/src/native/ffmpeg/ffmpegAddon.darwin.arm64.node new file mode 100644 index 00000000..f8b69143 Binary files /dev/null and b/src/native/ffmpeg/ffmpegAddon.darwin.arm64.node differ diff --git a/src/native/ffmpeg/ffmpegAddon.linux.arm64.node b/src/native/ffmpeg/ffmpegAddon.linux.arm64.node new file mode 100644 index 00000000..b11e66a2 Binary files /dev/null and b/src/native/ffmpeg/ffmpegAddon.linux.arm64.node differ diff --git a/src/native/ffmpeg/ffmpegAddon.linux.x64.node b/src/native/ffmpeg/ffmpegAddon.linux.x64.node new file mode 100644 index 00000000..a1916fdd Binary files /dev/null and b/src/native/ffmpeg/ffmpegAddon.linux.x64.node differ diff --git a/src/native/ffmpeg/ffmpegAddon.win.x64.node b/src/native/ffmpeg/ffmpegAddon.win.x64.node new file mode 100644 index 00000000..06054c75 Binary files /dev/null and b/src/native/ffmpeg/ffmpegAddon.win.x64.node differ