fix(cli): discover project-local ffmpeg binaries (#2464)

* fix(cli): discover project-local ffmpeg binaries

* style(cli): format project-local ffmpeg discovery

* style(media-use): format resolver script

* chore(skills): refresh bundled manifest
This commit is contained in:
Miguel Ángel
2026-07-15 00:37:18 -04:00
committed by GitHub
parent a04ce6a244
commit e3ca89e9ac
2 changed files with 23 additions and 1 deletions
+14
View File
@@ -22,6 +22,7 @@ afterEach(() => {
Object.defineProperty(process, "platform", { value: originalPlatform, configurable: true });
vi.clearAllMocks();
delete process.env.HYPERFRAMES_FFMPEG_PATH;
delete process.env.HYPERFRAMES_FFPROBE_PATH;
});
describe("findFFmpeg", () => {
@@ -53,6 +54,19 @@ describe("findFFmpeg", () => {
const { findFFmpeg } = await import("./ffmpeg.js");
expect(findFFmpeg()).toBeUndefined();
});
it("finds project-local FFmpeg binaries when they are not on PATH", async () => {
mockExec.mockImplementation(() => {
throw new Error("not found");
});
const localFFmpeg = resolve(".hyperframes", "bin", "ffmpeg");
const localFFprobe = resolve(".hyperframes", "bin", "ffprobe");
mockExists.mockImplementation((path) => path === localFFmpeg || path === localFFprobe);
const { findFFmpeg, findFFprobe } = await import("./ffmpeg.js");
expect(findFFmpeg()).toBe(localFFmpeg);
expect(findFFprobe()).toBe(localFFprobe);
});
});
describe("resolveH264EncoderMode", () => {
+9 -1
View File
@@ -87,13 +87,21 @@ function findInCommonDirs(name: "ffmpeg" | "ffprobe"): string | undefined {
return undefined;
}
function findInProjectLocalBin(name: "ffmpeg" | "ffprobe"): string | undefined {
const extension = process.platform === "win32" ? ".exe" : "";
const candidate = resolve(".hyperframes", "bin", `${name}${extension}`);
return existsSync(candidate) ? candidate : undefined;
}
function findConfiguredBinary(
envName: string,
binaryName: "ffmpeg" | "ffprobe",
): string | undefined {
const configured = process.env[envName]?.trim();
if (configured) return existsSync(configured) ? resolve(configured) : undefined;
return findOnPath(binaryName) ?? findInCommonDirs(binaryName);
return (
findOnPath(binaryName) ?? findInProjectLocalBin(binaryName) ?? findInCommonDirs(binaryName)
);
}
export function findFFmpeg(): string | undefined {