[vlc-devel] [PATCH 4/9] demux: mkv: fix DTS of outgoing blocks

Francois Cartegnie fcvlcdev at free.fr
Mon Jul 16 11:30:07 CEST 2018

Le 16/07/2018 à 11:15, Denis Charmet a écrit :

> Setting DTS when not having them is a gamble. It might fix some decoders
> and break some others. It's usually seen as acceptable for keyframes to
> set DTS = PTS for the others. I don't have an example so I won't fight
> it but beware :).

Unfortunately, after trying to fix RTSP where there never a DTS;

DTS = PTS on I-Frame isn't even correct, only B-frames not being
reference can be considered DTS = PTS in the case of H264.

That does not even work for H265 where I couldn't find any easy way
without computing the POC...

One dumb algorithm would be:
- Store the first N frames >= max_num_reorder/DPB
- On N, find the min PTS
- use min PTS it as DTS for the first block in decoding order
- increase PTS for each frame
- that also requires to handle drift (frame length can differ)
- there's some streams which are not packetized, so there's no "frames"
- possibly no pts on some block for the previous reason

We're in the same situation as RTSP where:
- we need DTS for PCR and correct buffering/timing
- we can't compute DTS without packetizer's work
An that would mean running packetizer before sending to es_out, rising
new issues with 1 frame delay and low fps.

Francois Cartegnie
VideoLAN - VLC Developer

More information about the vlc-devel mailing list