[Libav-user] DTS audio out of sync with video

Scott Brown scott.brown at movenetworks.com
Wed Feb 8 19:25:42 CET 2012

Ok, I have some more info about this problem. For some reason, it's taking
quite a while after the signal returns to get video frames, which is
strange because I start to get audio frames right away:

Here's my timeline:
12:00:00 start decoding
12:00:10 signal lost (av_read_frame waits)
12:00:25 signal returned, av_read_frame returns

Immediately after the signal comes back av_read_frame returns one or two
audio and video frames for 12:00:10 (before signal loss). Then right after
that (12:00:25) it starts returning some audio frames for the new time
(12:00:25). After reading a lot of audio packets, av_read_frame finally
starts to return some video frames, around 12:00:29. The first video frame
it returns is for 12:00:10 (before signal loss) and then right afterwards
it returns a video frame for 12:00:29. After this it reads audio and video
frames "normally", with DTS values that are out of sync. So playing the
audio for 12:00:30 with a video frame with a PTS of 12:00:30 ends up with
the audio that is a couple of seconds before the video.

Here's ffmpeg's log of what happens immediately following the signal
coming back (12:00:25):

[h264 @ 0x916b3c0] error while decoding MB 58 34, bytestream (-3)
[h264 @ 0x916b3c0] mmco: unref short failure
[h264 @ 0x916b3c0] reference picture missing during reorder
[h264 @ 0x916b3c0] Missing reference picture
[h264 @ 0x916b3c0] Increasing reorder buffer to 16
[h264 @ 0x916b3c0] illegal short term buffer state detected
[mpegts @ 0x9149a00] PES packet size mismatch
[ac3 @ 0x9171640] frame CRC mismatch
[ac3 @ 0x9171640] frame sync error
[h264 @ 0x916b3c0] reference picture missing during reorder
[h264 @ 0x916b3c0] Missing reference picture

I'm particularly concerned with the reorder buffer of 16. However, at 30
fps, even if this was the cause, the audio should only be off by 1/2 of a
second, but it's clearly more off than that.

As always, I appreciate any help you can give. Thanks

On 2/7/12 6:46 PM, "Kalileo" <kalileo at universalx.net> wrote:

>On Feb 8, 2012, at 06:44 , Scott Brown wrote:
>> My player is looking at PTS and DTS values, not just playing them as
>> come. If it's missing samples for a given time, it plays silence (for
>> audio). I don't set any flags when I open the transport stream,
>>although I
>> did once try setting the "mpeg2ts_compute_pcr" option to "1" in the
>> AVDictionary parameter. Although, since this didn't fix the problem I
>> removed it. Honestly though, I'm not even sure what it did.
>Then I would check if your input stream is not already containing wrong
>dts/pts values.
>Libav-user mailing list
>Libav-user at ffmpeg.org

More information about the Libav-user mailing list