Skip to content

Commit 97907b1

Browse files
committed
fix(studio-server): honor injected ffprobe runners
1 parent c019def commit 97907b1

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎packages/studio-server/src/helpers/mediaMetadata.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { describe, expect, it } from "vitest";
1+
import { afterEach, describe, expect, it, vi } from "vitest";
22
import { classifyMediaColor, pixelFormatHasAlpha, probeMediaMetadata } from "./mediaMetadata.js";
33

4+
afterEach(() => vi.unstubAllEnvs());
5+
46
describe("classifyMediaColor", () => {
57
it("detects HDR PQ from BT.2020 + smpte2084 metadata", () => {
68
expect(
@@ -123,7 +125,8 @@ describe("probeMediaMetadata", () => {
123125
});
124126
});
125127

126-
it("supports an async runner (the default execFile path is promise-based)", async () => {
128+
it("supports an injected async runner without requiring local ffprobe", async () => {
129+
vi.stubEnv("HYPERFRAMES_FFPROBE_PATH", "/definitely/missing/ffprobe");
127130
const metadata = await probeMediaMetadata("/tmp/clip.mp4", async () => ({
128131
status: 0,
129132
stdout: JSON.stringify({

‎packages/studio-server/src/helpers/mediaMetadata.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,11 @@ export async function probeMediaMetadata(
184184
return { kind, color: classifyMediaColor(null) };
185185
}
186186

187-
// Best-effort, like the hevc_preview_codec lint rule: an env override
188-
// pointing at a missing file, or no ffprobe on PATH at all, degrades to
189-
// "unavailable" rather than spawning a doomed-to-ENOENT child process.
190-
const ffprobePath = findFfBinary("ffprobe", { configuredMustExist: true });
187+
// The default runner degrades a missing ffprobe to "unavailable" without
188+
// spawning; injected runners own execution and receive the normal command.
189+
const ffprobePath =
190+
findFfBinary("ffprobe", { configuredMustExist: true }) ??
191+
(runner === execFileRunner ? undefined : "ffprobe");
191192
if (!ffprobePath) {
192193
return { kind, color: classifyMediaColor(null), probeError: "ffprobe unavailable" };
193194
}

0 commit comments

Comments
 (0)