[FFmpeg-user] understanding DTS PTS

Alexandre FERRIEUX - FT/RD/SIRP/ASF/SOFTL alexandre.ferrieux at orange-ftgroup.com
Wed Mar 4 11:05:00 CET 2009


Bouke wrote:
> ----- Original Message ----- 
> From: "Alexandre Ferrieux" <alexandre.ferrieux at orange-ftgroup.com>
> To: "FFmpeg user questions and RTFMs" <ffmpeg-user at mplayerhq.hu>
> Sent: Wednesday, March 04, 2009 9:25 AM
> Subject: Re: [FFmpeg-user] understanding DTS PTS
> 
> 
>> Marc Mason wrote:
>>> John wrote:
>>>
>>>> I am going through the ffmpeg tutorials and am having trouble making
>>>> sense of this statement in tutorial 5.
>>>>
>>>> <quote>
>>>> However, ffmpeg reorders the packets so that the DTS of the packet
>>>> being processed by avcodec_decode_video() will always be the same as
>>>> the PTS of the frame it returns.
>>>> </quote>
>>>>
>>>> What reordering is it talking about? From the example
>>>>
>>>> PTS: 1 4 2 3
>>>> DTS: 1 2 3 4
>>>> Stream: I P B B
>>>>
>>>> The frames are being read in I P B B. When P is being processed by
>>>> avcodec_decode_video() its DTS is 2. P's PTS cannot be 2. What frame
>>>> reordering is ffmpeg supposed to be doing? Thanks...
>>> Suppose we have 4 frames, and we decide to encode them the following 
>>> way: F1=I F2=B F3=B F4=P
>>>
>>> To encode F2 and F3, we need F4 (B frames).
>>>
>>> The presentation order (PTS) is F1, F2, F3, F4.
>>>
>>> But since the decoder needs F4 to decode F2 and F3, we can send them in 
>>> a different order : F1, F4, F2, F3 (the decoding order).
>>>
>>> The decoder will receive frames in the following order.
>>>
>>> F1 DTS=1 PTS=1
>>> F4 DTS=2 PTS=4
>>> F2 DTS=3 PTS=2
>>> F3 DTS=4 PTS=3
>> OK, but what purpose does the DTS serve then ?
>>
>> -Alex
> 
> Tell the decoder when to display the frames (thus, in the correct order)

Sorry my question was not precise :-)
I mean, what is the added value of DTS expressed in a fine-grained clock 
over simple sequence numbers incremented by one (which can even be 
implicit since the DTS order is exactly the incoming order) ?

-Alex



More information about the ffmpeg-user mailing list