Skip to content
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

Don't try to match anchor track fragmenting after it is finished. #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jgreer
Copy link
Contributor

@jgreer jgreer commented Dec 29, 2015

When a secondary track (audio) is slightly longer than the anchor track (video), the mp4fragment tries to match the fragment durations, creating an unexpected short segment at the end, like so:

fragment: track ID 1  60 samples
fragment: track ID 2  86 samples
fragment: track ID 1  60 samples
fragment: track ID 2  86 samples
fragment: track ID 1  32 samples
fragment: track ID 2  46 samples
fragment: track ID 2   3 samples

So each fragment is approximately 2 seconds, except the final video fragment is about 1.07 seconds. The audio is then fragmented into a 1.07 second fragment and a 0.035 second fragment, so that its durations match the video.

Instead, the final audio fragment should be allowed to be up to 2 seconds long, ensuring consistent fragmenting. With this patch applied, the fragmenting looks like the following:

fragment: track ID 1  60 samples
fragment: track ID 2  86 samples
fragment: track ID 1  60 samples
fragment: track ID 2  86 samples
fragment: track ID 1  32 samples
fragment: track ID 2  49 samples

…t duration rather than trying to match anchor track.
@barbibulle
Copy link
Contributor

The current behavior may seem a bit odd, but there's a rationale behind it: the tool tries to match audio and video segments so they are of equal duration. If the audio is too long, then you do end up with an "extra" segment of audio, which you would normally ignore (there shouldn't be more audio than video in a normal presentation).
There's a command line option, --trim, which can be used to simply discard this extra media in case the media is mismatched.

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.

None yet

2 participants