[vlc-devel] [RFC] Don't trust the PCR by default

Francois Cartegnie fcvlcdev at free.fr
Mon Mar 17 04:42:33 CET 2014

Le 16/03/2014 19:10, Denis Charmet a écrit :
> The TS demux is PCR master but broken streams may have invalid PCR which stops the playback or at least the playback of some tracks.
> Those file can be played with --demux=avformat since it uses the minimum dts off all the tracks as PCR.
> The following patch implements the same thing.
> Any idea/comments on this PoC?

This kind of fix needs an observation window, or can't be that easy.

You can't ask the user to specify to trust pcr or not. Otherwise, just
use avcodec. So you need to check is PCR is accurate, and estimate gap
which needs to watch some packets.

Then taking the lowest DTS after means packets have already been sent
(and PCR must have been set too) and you're probably setting a new
PCR<DTS value for, at least, one track.

Furthermore, the rollover needs to be handled too from that point as
DTS/PCR might now be set in pre-rollover values while PTS might be post
rollover. We are also killing the purpose of PCR.

According to the spec, DTS is always monotonically increasing. So we
might only need to pick the first DTS of the first packet we see,
assuming there's not violation of that part of the spec.

And to keep the PCR clock signals, we could compute a (DTS - PCR) offset
which would be applied to any other stamp. But this means, again, to set
an observation window, which requires preseek or to buffer blocks
(annoying for 4K) until an undefined deadline (*).

(*) seen all pid from that PMT or dts difference > 2*CLOCK_FREQ.


More information about the vlc-devel mailing list