Skip to content

Conversation

@chidanandm-wq
Copy link
Collaborator

PR Title

Improve DTS pass-through handling to maintain contiguous MP4 timelines

Description
This PR enhances the DTSPassThroughStrategy to make MP4 timeline generation more robust when dealing with irregular or unstable source timestamps.

Problem
In pass-through DTS mode, raw frame timestamps from the source can:
Jump forward significantly (e.g., due to connectivity drops or source jitter)
The cases lead to non-contiguous DTS values in the generated MP4, causing issues with seeking, playback smoothness, and timeline consistency.

Solution
The DTSPassThroughStrategy::getDTS() logic has been updated to normalize and clamp frame timestamps while still preserving pass-through behavior as much as possible:
Large positive jumps (diffInMsecs > ideal frame duration)
Clamps the jump to one ideal frame duration to keep the MP4 timeline contiguous, with a warning log for visibility.

Key Changes:
Introduced calculation of:
idealDurationInMsecs (1000 / fps)
maxJumpInMsecs (equal to ideal frame duration)
Added explicit clamping for large timestamp gaps
Added log when timestamp jumps are corrected

Impact:
Ensures monotonically increasing DTS values
Prevents large gaps in MP4 timelines

Improves seek accuracy and playback stability

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.

2 participants