Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(web): expand ffmpeg binary search paths

Richie McIlroycab894bef169
diff --git a/apps/web/lib/audio-extract.ts b/apps/web/lib/audio-extract.ts
index a966c6445..1f68c2e5f 100644
--- a/apps/web/lib/audio-extract.ts
+++ b/apps/web/lib/audio-extract.ts
@@ -2,11 +2,18 @@ import { spawn } from "node:child_process";
import { randomUUID } from "node:crypto";
import { existsSync, promises as fs } from "node:fs";
import { tmpdir } from "node:os";
-import { join, resolve } from "node:path";
+import { delimiter, join, resolve } from "node:path";
import ffmpegStaticPath from "ffmpeg-static";
let cachedFfmpegPath: string | null = null;
+function getPathCandidates(): string[] {
+ return (process.env.PATH ?? "")
+ .split(delimiter)
+ .filter(Boolean)
+ .map((segment) => join(segment, "ffmpeg"));
+}
+
export function getFfmpegPath(): string {
if (cachedFfmpegPath) {
return cachedFfmpegPath;
@@ -21,6 +28,11 @@ export function getFfmpegPath(): string {
),
"/var/task/node_modules/ffmpeg-static/ffmpeg",
"/var/task/node_modules/.pnpm/[email protected]/node_modules/ffmpeg-static/ffmpeg",
+ process.env.FFMPEG_PATH,
+ "/opt/homebrew/bin/ffmpeg",
+ "/usr/local/bin/ffmpeg",
+ "/usr/bin/ffmpeg",
+ ...getPathCandidates(),
].filter(Boolean) as string[];
for (const path of candidatePaths) {