mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-05 00:56:23 +00:00
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:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user