[FFmpeg-trac] Audio sync issue with MP4's with two stereo audio streams

Gina Collecchia ginacollecchia at gmail.com
Tue Jul 25 22:07:48 EEST 2017


I’ve been trying to drill down the root cause of this bug for some time, and I’m very curious if any of you have seen it!

In muxing an H264 video file with two stereo AAC audio streams into an MP4 container, the second audio stream is of varying duration, and occasionally even out of sync with the first audio stream.

In blue, see the end of an MP4 with video attached, and the difference in durations of its two audio streams. In green, the same MP4 (still 2 stereo audio steams, AAC) with the video stripped (this is the audio source, right before it is attached to the video). This is in Adobe Premiere, the only way I’ve actually been able to confirm the error.

We expect some level of duration change with AAC conversion, but I am wondering why they go out of sync. Furthermore, the two streams seem in sync right up until the end—around 1:08:00, they look pretty in sync, but some point before 1:08:45, the second stream apparently drops some samples. I have frequently seen this sync off by exactly 400 milliseconds (related to a 60fps frame rate—24 frames), but not consistently—and this is a shorter clip, so that might be why. But I have not determined that the sync difference is a function of total duration.

Unfortunately, stripping the audio from the blue video file does not retain the error: the mono WAV files exported from Premiere (or extracted from FFmpeg) are all of identical duration and synced, as in the green waveform display. And FFprobe only reports one duration for the whole file.

It does cause issues in playback as the file will hang at the very end, because of the missing data in the second audio stream.

I’ve considered a hack to just add 0’s at the end of the second audio stream, but I would need a way to determine the duration difference programmatically. 

Any feedback appreciated.


Gina Collecchia
http://ginacollecchia.com <http://ginacollecchia.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/ffmpeg-trac/attachments/20170725/be77382c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2017-07-25 at 11.42.19 AM.png
Type: image/png
Size: 39271 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-trac/attachments/20170725/be77382c/attachment.png>

More information about the FFmpeg-trac mailing list