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

Scott Brown scott.brown at movenetworks.com
Wed Feb 8 00:44:47 CET 2012


My player is looking at PTS and DTS values, not just playing them as they
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.

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

>
>On Feb 8, 2012, at 03:58 , Scott Brown wrote:
>
>> 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.
>
>When you say "the audio and video are no longer in sync. The audio is
>about 2 seconds before the video." I assume you come to this conclusion
>when you play the stream. Does your player have any mechanism to
>synchronize based on DTS/PTS, or is it simply playing the audio/video
>frames as they come?
>
>The streams I have worked with have always had a usable DTS/PTS, If there
>were frames missing/arriving corrupted then the DTS/PTS would show a
>"jump" and the player could sync back based on DTS/PTS.
>
>Thus, to my experience, the answer is "No" to your question "For a
>transport stream, is the PTS/DTS dependent on the packets before it?".
>
>What flags do you set when you open the stream? IIRC there is a flag to
>"fill in" corrected PTS values. I've never set such a flag.
>
>
>
>_______________________________________________
>Libav-user mailing list
>Libav-user at ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/libav-user



More information about the Libav-user mailing list