test(producer): add stream duration parity check to regression harness (#1652)

Probes the rendered output for video and audio stream durations after
render and fails the test if they differ by more than 0.5s. Catches
mux-level truncation regressions like the ffmpeg -shortest bug (#1648)
where one stream gets silently cut short.

Runs on all non-png-sequence fixtures with audio — no new meta.json
field needed since this is a universal invariant, not a per-fixture
threshold.
This commit is contained in:
Miguel Ángel
2026-06-22 18:32:59 -04:00
committed by GitHub
parent 4976b5e036
commit 60d3eeb1f7
9 changed files with 383 additions and 3 deletions
+6
View File
@@ -81,6 +81,10 @@ export interface VideoMetadata {
export interface AudioMetadata {
durationSeconds: number;
/** Audio stream's own duration (from `stream.duration`), falling back to
* container duration when the stream field is absent. Prefer this over
* `durationSeconds` for stream-level parity checks. */
streamDurationSeconds?: number;
sampleRate: number;
channels: number;
audioCodec: string;
@@ -363,9 +367,11 @@ export async function extractAudioMetadata(filePath: string): Promise<AudioMetad
if (!audioStream) throw new Error("[FFmpeg] No audio stream found");
const durationSeconds = output.format.duration ? parseFloat(output.format.duration) : 0;
const streamDuration = audioStream.duration ? parseFloat(audioStream.duration) : undefined;
return {
durationSeconds,
streamDurationSeconds: streamDuration && streamDuration > 0 ? streamDuration : undefined,
sampleRate: audioStream.sample_rate ? parseInt(audioStream.sample_rate) : 44100,
channels: audioStream.channels || 2,
audioCodec: audioStream.codec_name || "unknown",