()
| 15 | } |
| 16 | |
| 17 | export function getFfmpegPath(): string { |
| 18 | if (cachedFfmpegPath) { |
| 19 | return cachedFfmpegPath; |
| 20 | } |
| 21 | |
| 22 | const candidatePaths = [ |
| 23 | ffmpegStaticPath, |
| 24 | resolve(process.cwd(), "node_modules/ffmpeg-static/ffmpeg"), |
| 25 | resolve( |
| 26 | process.cwd(), |
| 27 | "node_modules/.pnpm/ffmpeg-static@5.3.0/node_modules/ffmpeg-static/ffmpeg", |
| 28 | ), |
| 29 | "/var/task/node_modules/ffmpeg-static/ffmpeg", |
| 30 | "/var/task/node_modules/.pnpm/ffmpeg-static@5.3.0/node_modules/ffmpeg-static/ffmpeg", |
| 31 | process.env.FFMPEG_PATH, |
| 32 | "/opt/homebrew/bin/ffmpeg", |
| 33 | "/usr/local/bin/ffmpeg", |
| 34 | "/usr/bin/ffmpeg", |
| 35 | ...getPathCandidates(), |
| 36 | ].filter(Boolean) as string[]; |
| 37 | |
| 38 | for (const path of candidatePaths) { |
| 39 | if (existsSync(path)) { |
| 40 | cachedFfmpegPath = path; |
| 41 | return path; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | throw new Error( |
| 46 | `FFmpeg binary not found. Tried paths: ${candidatePaths.join(", ")}`, |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | export interface AudioExtractionResult { |
| 51 | filePath: string; |
no test coverage detected