aqua-feel sync: a failed ffmpeg read is an error; test the CLI carries the frame gaps
Soul found that an ENOBUFS-truncated showinfo list gave a plausible rate with the stalls measured only on the file's start, and that deleting the visualGapMs line in feel.mjs left every check green. Both now fail a test. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
947911971d
commit
e62ac52c37
2 changed files with 13 additions and 2 deletions
|
|
@ -100,7 +100,7 @@ export function sourceFrames(showinfo) {
|
|||
// Stream start_time offsets are applied so both clocks are the container's clock; video is resampled to constant frame rate by pts.
|
||||
export function readVideo(path, { ffmpeg = process.env.FFMPEG ?? "ffmpeg", targetFps } = {}) {
|
||||
// ffmpeg only (no ffprobe: static builds ship without it). `ffmpeg -i` lists the streams; the first decoded frame of each stream says when it starts.
|
||||
const run = (a) => { const r = spawnSync(ffmpeg, a, { encoding: "utf8", maxBuffer: 1 << 26 }); if (r.error?.code === "ENOENT") throw new Error("ffmpeg is not on PATH (set FFMPEG=/path/to/ffmpeg); give --wav and --track instead"); return String(r.stderr ?? ""); };
|
||||
const run = (a) => { const r = spawnSync(ffmpeg, a, { encoding: "utf8", maxBuffer: 1 << 26 }); if (r.error?.code === "ENOENT") throw new Error("ffmpeg is not on PATH (set FFMPEG=/path/to/ffmpeg); give --wav and --track instead"); if (r.error) throw new Error(`ffmpeg failed (${r.error.code}): its frame list may be truncated, so the capture's stalls would be under-measured`); return String(r.stderr ?? ""); };
|
||||
const lines = run(["-hide_banner", "-i", path]).split("\n"), find = (kind) => lines.find((l) => new RegExp(`Stream #\\d+:\\d+.*: ${kind}:`).test(l));
|
||||
const vl = find("Video"), al = find("Audio");
|
||||
if (!vl || !al) throw new Error("file needs one video and one audio stream");
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ t("sourceFrames: the rate is the median frame gap, the stale-frame bound is the
|
|||
|
||||
// The video path needs ffmpeg (FFMPEG=/path or on PATH); skipped, and said so, when there is none.
|
||||
{
|
||||
const { readVideo } = await import("./sync.mjs"), { execFileSync } = await import("node:child_process");
|
||||
const { readVideo } = await import("./sync.mjs"), { execFileSync } = await import("node:child_process"), require_fs = await import("node:fs"), { tmpdir } = await import("node:os"), { join } = await import("node:path");
|
||||
const ff = process.env.FFMPEG ?? "ffmpeg";
|
||||
let have = true; try { execFileSync(ff, ["-version"], { stdio: "ignore" }); } catch { have = false; }
|
||||
if (!have) console.log("skip video path: no ffmpeg (set FFMPEG)");
|
||||
|
|
@ -252,6 +252,17 @@ t("sourceFrames: the rate is the median frame gap, the stale-frame bound is the
|
|||
for (const p of r.pairs) assert.ok(p.lagHighMs - p.lagLowMs >= v.sourceGapMs * 1.5, `interval ${p.lagHighMs - p.lagLowMs} ms narrower than the capture's own stalls`);
|
||||
assert.match(formatSync(r), /source frames are up to that far apart/);
|
||||
});
|
||||
if (have) t("the CLI carries the capture's frame gaps into its report (feel.mjs plumbing)", () => {
|
||||
const { mkdtempSync, readFileSync: rf } = require_fs, out = join(mkdtempSync(join(tmpdir(), "sync-cli-")), "r.json");
|
||||
execFileSync("node", [new URL("./feel.mjs", import.meta.url).pathname, "sync", "--video", new URL("./fixtures/perlines-aurora-vfr.webm", import.meta.url).pathname, "--allow-unpaired", "--no-gate", "--json", out], { env: { ...process.env, FFMPEG: ff }, stdio: "ignore" });
|
||||
const r = JSON.parse(rf(out, "utf8"));
|
||||
assert.ok(r.visualGapMs > 1000 / 59 * 1.5, `visualGapMs ${r.visualGapMs}`); assert.equal(r.framePeriodMs, r.visualGapMs);
|
||||
});
|
||||
if (have) t("a failed ffmpeg read (e.g. output buffer overflow) is an error, not a quietly shorter frame list", () => {
|
||||
const { mkdtempSync, writeFileSync: wf, chmodSync } = require_fs, d = mkdtempSync(join(tmpdir(), "sync-stub-")), stub = join(d, "ffmpeg");
|
||||
wf(stub, "#!/bin/sh\nhead -c 70000000 /dev/zero | tr '\\0' 'x' >&2\n"); chmodSync(stub, 0o755);
|
||||
assert.throws(() => readVideo(new URL("./fixtures/perlines-aurora-vfr.webm", import.meta.url).pathname, { ffmpeg: stub }), /ffmpeg failed \(ENOBUFS\)/);
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`${n} sync checks passed. Fixtures only (synthetic, plus one browser capture when ffmpeg is present); nothing was heard or seen.`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue