[FFmpeg-devel] mpegtsenc: Improve PCR generation and output

Tomas Härdin tomas.hardin
Thu Sep 30 16:07:59 CEST 2010


Hi

While working some more on remuxing dvbsub in mpegts I noticed that the
longer the sample I used was, the higher the muxdelay I needed in order
to avoid the "dts < pcr, TS is invalid" warning.

This is due to how the current muxer calculates PCR. It simply
accumulates TS_PACKET_SIZE*8*90000LL/ts->mux_rate in cur_pcr. Unless
your mux_rate evenly divides 135360000 (TS_PACKET_SIZE*8*90000) this
will cause rounding errors which quickly lead to unacceptable PCR drift.

A second problem is that it only uses 90 kHz precision, when it should
use 27 MHz. 90 kHz is insufficient to stay within the allowed +- 500 ns
jitter.

The attached patch calculates PCR based on max_delay and the current
size of the output, in 27 MHz. This method should eliminate any PCR
drift caused by the rounding errors in the previous solution. It also
outputs the full PCR.

The patch passes the regtests, but that seems to be because there are
none for mpegts. Maybe some should be added?

/Tomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mpegtsenc_pcr.patch
Type: text/x-patch
Size: 5016 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100930/1bf7f1af/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100930/1bf7f1af/attachment.pgp>



More information about the ffmpeg-devel mailing list