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

Scott Brown scott.brown at movenetworks.com
Tue Feb 7 21:58:34 CET 2012

Hey everyone,

I'm using ffmpeg libraries to read from a UDP transport stream, and I've been working on handling short term signal loss if ffmpeg can no longer read from the UDP stream. Basically the call to av_read_frame() takes a long time (up to a minute or so) and then begins reading packets again.

The trouble I have is with the PTS and DTS for the audio and video. Specifically, the audio and video are no longer in sync. The audio is about 2 seconds before the video. So if a video frame has the same PTS as a audio frame, during playback the video looks like it's behind the audio, even though the PTS is the same. Interestingly enough, this only happens after signal loss. If there is no signal loss, everything looks great.

For a transport stream, is the PTS/DTS dependent on the packets before it? I've tried clearing out the AVFormatContext packet_buffer via calling the ff_frame_flush function, but this didn't help. Does anyone know why the audio and video get out of sync if packets are lost?

Thanks for the help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120207/1f00e4c1/attachment.html>

More information about the Libav-user mailing list