mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
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:
@@ -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", () => {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user