[FFmpeg-user] DTSs & PTSs in MPEG2-TS streams

Devin Heitmueller devin.heitmueller at ltnglobal.com
Thu Feb 1 16:54:45 EET 2024


Hi Mark,

On Thu, Feb 1, 2024 at 1:15 AM Mark Filipak <markfilipak.imdb at gmail.com> wrote:
>
> FFmpeg assigns DTSs & PTSs to P-frames and B-frames in MPEG2-TS streams. How does it determine those
> DTSs & PTSs?
>
> Since DTSs & PTSs don't actually exist for P-/B-frames in MPEG2-TS streams, FFmpeg must have a way
> that's unknown to me.

P/B frames can certainly have PTS values.  In fact, you have to have
PTS values in B frames since they differ from the DTS (since with B
frames the presentation order differs from the decoding order).

There are potentially cases with some streams where the PTS and/or DTS
is not specified for every frame, in which case libavformat will
interpolate those values based on the frame duration and the prior
packet.  This is more common for audio, where you might have multiple
audio AU payloads within a single PES packet.

> I'm seeing some strange things. They can't be as strange as they look because they look disastrous.
> At issue is the cause of non-monotonous DTSs and obviously bogus DTSs for P-frames such as
> '-9223372036854775808'.

9223372036854775808 is a magic number.  It corresponds to the #define
for AV_NOPTS_VALUE.  If you see that value it means that the packet
did not have a PTS or DTS value assigned to it and thus you may have
to take special measures.

Devin

-- 
Devin Heitmueller, Senior Software Engineer
LTN Global Communications
o: +1 (301) 363-1001
w: https://ltnglobal.com  e: devin.heitmueller at ltnglobal.com


More information about the ffmpeg-user mailing list