Lazy FFmpeg binary resolution (ffmpeg-static, then system), mirroring lib/audio/extractor.ts.
()
| 14 | |
| 15 | /** Lazy FFmpeg binary resolution (ffmpeg-static, then system), mirroring lib/audio/extractor.ts. */ |
| 16 | function ensureFfmpeg(): void { |
| 17 | if (ffmpegInitialized) { |
| 18 | if (!ffmpegPath) { |
| 19 | throw new Error( |
| 20 | 'FFmpeg not found. Install: brew install ffmpeg (macOS) / apk add ffmpeg (Alpine) / apt-get install ffmpeg (Ubuntu)' |
| 21 | ) |
| 22 | } |
| 23 | return |
| 24 | } |
| 25 | ffmpegInitialized = true |
| 26 | |
| 27 | if (ffmpegStatic && typeof ffmpegStatic === 'string') { |
| 28 | try { |
| 29 | fsSync.accessSync(ffmpegStatic, fsSync.constants.X_OK) |
| 30 | ffmpegPath = ffmpegStatic |
| 31 | ffmpeg.setFfmpegPath(ffmpegPath) |
| 32 | return |
| 33 | } catch { |
| 34 | // fall through to system ffmpeg |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | try { |
| 39 | const cmd = process.platform === 'win32' ? 'where ffmpeg' : 'which ffmpeg' |
| 40 | ffmpegPath = execSync(cmd, { encoding: 'utf-8' }).trim().split('\n')[0] |
| 41 | ffmpeg.setFfmpegPath(ffmpegPath) |
| 42 | } catch { |
| 43 | logger.warn('[FFmpeg] No FFmpeg binary found at init time') |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | export type FfmpegOperation = |
| 48 | | 'overlay_audio' |
no test coverage detected