fix: audio/video sync drift in fixMP4BoxFileDuration
#446
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello! This PR fixes a small issue leading to audio/video sync drift when using
fastConcatMP4
to concatenate mp4s.The problem: if input MP4 streams to
fastConcatMP4
contain internal timestamp offsets that don't start at 0, cumulative A/V drift occurs during concatenation, making the video not match the audio. This was affecting both audio and video, a video output fromfastConcatMP4
is both the wrong duration and showing a/v drift, and also dropping frames due to the incorrectly calculated durations.This fixes it by normalizing sample timestamps within each stream to start from 0 before applying concatenation offsets, ensuring the correct duration is calculated. This also synchronizes audio timing to the video timeline to maintain correct a/v sync.
I don't have a repro case I can share right now but can provide if needed.