Skip to content

fix(engine): report the stream duration as the keyframe interval for single-GOP videos - #3971

Open
ravsau wants to merge 1 commit into
heygen-com:mainfrom
ravsau:fix/single-keyframe-interval
Open

ravsau wants to merge 1 commit into
heygen-com:mainfrom
ravsau:fix/single-keyframe-interval

Conversation

@ravsau

@ravsau ravsau commented Sep 15, 2026

Copy link
Copy Markdown

Closes #3460

analyzeKeyframeIntervals returned isProblematic: false for any video with fewer than two keyframes. A video with exactly one keyframe is one GOP spanning the whole file, so every seek past 0 decodes from the start. The compiler warned about a 5s GOP and stayed silent about a 10s one.

This change splits the early return. Zero keyframes (still images) keep the old result. One keyframe now reports the video stream's duration as both the average and max interval, and flags the file when that duration exceeds the existing 2s threshold. It reads videoStreamDurationSeconds from the cached extractMediaMetadata probe, per the maintainer note on the issue: a 1s picture in a 10s audio container has a 1s GOP, so the container duration is the wrong number.

Scope: interval math only. The warning text in compileForRender is unchanged.

Repro (from the issue), before and after, on macOS with ffmpeg 8:

single-gop.mp4       before {"avgIntervalSeconds":0,"maxIntervalSeconds":0,"keyframeCount":1,"isProblematic":false}
single-gop.mp4       after  {"avgIntervalSeconds":10,"maxIntervalSeconds":10,"keyframeCount":1,"isProblematic":true}
five-second-gop.mp4  both   {"avgIntervalSeconds":5,"maxIntervalSeconds":5,"keyframeCount":2,"isProblematic":true}

Tests: three new cases in ffprobe.test.ts (single keyframe over 2s flags, short video stream inside a long audio container does not flag, zero keyframes stays silent). oxfmt --check, oxlint, engine tsc --noEmit, and the producer mediaProbeConcurrency test pass.

…single-GOP videos

analyzeKeyframeIntervals returned isProblematic: false for any video with
fewer than two keyframes. A video with exactly one keyframe is one GOP
spanning the whole file, so every seek past 0 decodes from the start.

Zero keyframes keeps the old result. One keyframe now reports the video
stream's duration as the interval and flags the file over the existing 2s
threshold. The video stream duration, not the container duration, is used
so a 1s picture inside a 10s audio container is not flagged.

Closes heygen-com#3460
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sparse-keyframe check silently skips single-keyframe videos — the worst case goes unreported (0.8.10)

1 participant