-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
@remotion/media: Fix frames being rendered out of order in <Video> for rendering
#6253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes an issue where video frames were being rendered out of order in the <Video> component during rendering. The root cause is that keyframe packet timestamps can be higher than the timestamps of packets that follow them (e.g., keyframe at 0.08s, next packet at 0.04s).
Key Changes:
- Updated timestamp handling to use
Math.min()when determining start timestamps to account for out-of-order packet timestamps - Added safeguards to cache eviction loops with maximum attempt limits and warning messages when limits are exceeded
- Renamed and reduced the safe window constant from
SAFE_BACK_WINDOW_IN_SECONDS(1 second) toSAFE_WINDOW_OF_MONOTOCY(0.2 seconds)
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/media/src/caches.ts | Renamed and reduced the safe window constant from 1 to 0.2 seconds |
| packages/media/src/video-extraction/keyframe-manager.ts | Updated to use Math.min() for start timestamps, added max attempts for cache eviction, and added requestedTimestamp parameter |
| packages/media/src/video-extraction/keyframe-bank.ts | Removed timestamp adjustment logic and changed to return first available frame instead of null |
| packages/media/src/video-extraction/get-frames-since-keyframe.ts | Added requestedTimestamp parameter and applied rounding to timestamps for sample iterator |
| packages/media/src/audio-extraction/audio-manager.ts | Added max attempts safeguard to cache eviction loop with warning message |
| packages/media/src/audio-extraction/audio-iterator.ts | Updated to use renamed constant |
packages/media/src/video-extraction/get-frames-since-keyframe.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…v/remotion into fix-duplicate-frames
No description provided.