MCPcopy
hub / github.com/CapSoftware/Cap / getFfmpegPath

Function getFfmpegPath

apps/web/lib/audio-extract.ts:17–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15}
16
17export 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
50export interface AudioExtractionResult {
51 filePath: string;

Callers 5

runFfmpegFunction · 0.90
extractAudioFromUrlFunction · 0.85
extractAudioToBufferFunction · 0.85
convertWavToMp3Function · 0.85
checkHasAudioTrackFunction · 0.85

Calls 2

getPathCandidatesFunction · 0.85
resolveFunction · 0.70

Tested by

no test coverage detected