Skip to content

Commit a3e6ee0

Browse files
vanceingallsclaude
andcommitted
fix(cli,core,lint,producer): terminate ffprobe options at every call site
#2740 added `--` to one of nine independent ffprobe invocations, so the bug class it closed stayed open everywhere else while CI reported it fixed — the regression test asserts the argv of that single site. Reproduced on ffprobe 8.1.1: an asset named `-intro.mp4` probes fine through extractMediaMetadata but fails with "Missing argument for option 'intro.mp4'" in audio pad/trim (mid-render), `hyperframes init`, whisper duration probing and webmAlphaCheck. hevcPreviewLint catches and returns false, so a dash-prefixed HEVC preview silently passes the lint rule. Terminated at all of them: producer/services/render/audioPadTrim.ts (x2) producer/plan-parity-analysis.ts cli/commands/init.ts cli/utils/webmAlphaCheck.ts cli/whisper/transcribe.ts (x2) core/mediaGradeAnalyzer.ts lint/hevcPreviewLint.ts audioPadTrim's runFfprobeJson is a near-verbatim clone of the engine's runFfprobe and structurally cannot add the terminator itself, because callers bake the input path into `args`. It now asserts the terminator is present rather than letting a dash-prefixed path through, takes the same stdio ["ignore", ...] as the engine helper, and redacts its stderr — it was throwing raw ffprobe output, which echoes the input path, into logs and telemetry. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent fbb2735 commit a3e6ee0

7 files changed

Lines changed: 20 additions & 4 deletions

File tree

packages/cli/src/commands/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function probeVideo(filePath: string): VideoMeta | undefined {
109109
if (!ffprobePath) return undefined;
110110
const raw = execFileSync(
111111
ffprobePath,
112-
["-v", "quiet", "-print_format", "json", "-show_format", "-show_streams", filePath],
112+
["-v", "quiet", "-print_format", "json", "-show_format", "-show_streams", "--", filePath],
113113
{ encoding: "utf-8", timeout: 15_000 },
114114
);
115115

packages/cli/src/utils/webmAlphaCheck.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ function probeWebmAlpha(filePath: string): WebmAlphaProbe {
8686
"stream=codec_name:stream_tags=alpha_mode",
8787
"-of",
8888
"json",
89+
"--",
8990
filePath,
9091
],
9192
{ encoding: "utf-8", timeout: 15_000 },

packages/cli/src/whisper/transcribe.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ function getMediaDurationSeconds(filePath: string): number | null {
171171
"format=duration",
172172
"-of",
173173
"default=noprint_wrappers=1:nokey=1",
174+
"--",
174175
filePath,
175176
],
176177
{ encoding: "utf-8", timeout: 10_000 },
@@ -329,7 +330,7 @@ function isWav16kMono(filePath: string): boolean {
329330
if (!ffprobePath) return false;
330331
const raw = execFileSync(
331332
ffprobePath,
332-
["-v", "quiet", "-print_format", "json", "-show_streams", filePath],
333+
["-v", "quiet", "-print_format", "json", "-show_streams", "--", filePath],
333334
{ encoding: "utf-8", timeout: 10_000 },
334335
);
335336
const parsed: {

packages/core/src/mediaGradeAnalyzer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ function probeMedia(mediaPath: string, ffprobePath: string): GradeMediaProbe {
121121
"stream=color_space,color_transfer,color_primaries,pix_fmt,duration:format=duration",
122122
"-of",
123123
"json",
124+
"--",
124125
mediaPath,
125126
],
126127
{ encoding: "utf8", timeout: 5_000, stdio: ["ignore", "pipe", "pipe"] },

packages/lint/src/hevcPreviewLint.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ async function probeIsHevc(ffprobePath: string, filePath: string): Promise<boole
5555
"stream=codec_name",
5656
"-of",
5757
"json",
58+
"--",
5859
filePath,
5960
]);
6061
return hasHevcStream(JSON.parse(stdout));

packages/producer/src/plan-parity-analysis.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ function probeMetadata(outputPath: string): PlanParityStreamMetadata {
119119
].join(":"),
120120
"-of",
121121
"json",
122+
"--",
122123
outputPath,
123124
]);
124125
return normalizeFfprobeMetadata(JSON.parse(bytes.toString("utf-8")) as unknown);

packages/producer/src/services/render/audioPadTrim.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
trackChildProcess,
3131
type AudioMetadata,
3232
} from "@hyperframes/engine";
33+
import { redactTelemetryString } from "@hyperframes/core";
3334

3435
/**
3536
* Tolerance used to decide whether an audio file is already short enough to
@@ -361,6 +362,7 @@ async function defaultProbeVideoFrameInfo(
361362
"stream=nb_frames,r_frame_rate",
362363
"-of",
363364
"json",
365+
"--",
364366
videoPath,
365367
],
366368
signal,
@@ -381,6 +383,7 @@ async function defaultProbeVideoFrameInfo(
381383
"stream=nb_read_packets,r_frame_rate",
382384
"-of",
383385
"json",
386+
"--",
384387
videoPath,
385388
],
386389
signal,
@@ -434,7 +437,13 @@ async function defaultRunFfmpeg(
434437
// ── ffprobe JSON runner (shared between fast/slow video probe paths) ─────
435438

436439
async function runFfprobeJson<T>(args: string[], signal?: AbortSignal): Promise<T> {
437-
const proc = spawn(getFfprobeBinary(), args);
440+
// Callers bake the input path into `args` (terminated with "--"), so this
441+
// helper cannot add the terminator itself — assert they did rather than
442+
// let a dash-prefixed path silently reach ffprobe as an option.
443+
if (!args.includes("--")) {
444+
throw new Error('[audioPadTrim] ffprobe args must terminate options with "--".');
445+
}
446+
const proc = spawn(getFfprobeBinary(), args, { stdio: ["ignore", "pipe", "pipe"] });
438447
trackChildProcess(proc);
439448
let stdout = "";
440449
proc.stdout.on("data", (data: Buffer) => {
@@ -452,7 +461,9 @@ async function runFfprobeJson<T>(args: string[], signal?: AbortSignal): Promise<
452461
throw outcome.error ?? new Error(outcome.stderr);
453462
}
454463
if (outcome.reason !== "exit" || outcome.exitCode !== 0) {
455-
throw new Error(`ffprobe ${outcome.reason}: ${outcome.stderr}`);
464+
// Redacted: raw ffprobe stderr echoes the input path, and this message
465+
// reaches logs and telemetry.
466+
throw new Error(`ffprobe ${outcome.reason}: ${redactTelemetryString(outcome.stderr, 2000)}`);
456467
}
457468
try {
458469
return JSON.parse(stdout) as T;

0 commit comments

Comments
 (0)