[FFmpeg-devel] [bug/patch] MPEG-TS muxer: PCR not in sync with PTS/DTS

Alexandre Ferrieux alexandre.ferrieux
Thu Sep 3 12:13:52 CEST 2009

Hi Niobos,

Niobos wrote:
>> I think it would be easier to generate a CBR transport stream, however
>> I think it's good to generate a VBR ts if it works :)
>> Well, for my purpose, a VBR would be very nice, so I'll look into that.
> Finally got around to do this. I reworked the previous patch quite a lot.
> In attachement:
> * ffmpeg-mpegts-freq-period-rename2: addition to the previous patch: I 
> forgot one.
> * ffmpeg-mpegts-vbr: Changes to support VBR Transport Streams
> * 2 graphs showing the timing in the first 1000 TS-packets of my 
> test-stream, illustrating the effect of the changes
> Both patches are against svn19750.
> Summary of changes:
> * Changed the calculation of total_bit_rate to be more accurate
> * Specifying -muxrate on the command line switches to CBR mode; no 
> -muxrate means VBR
> * I increased the log-level of the av_log to display the calculated 
> bitrates by default. This should facilitate the users to determine the 
> correct CBR muxrate
> * To maintain a CBR stream, null-packets are inserted when DTS drifts 
> from PCR
> * To maintain DTS/PCR sync in VBR streams, the PCR is increased without 
> a null-packet
> * Since the PCR is only stepped forward, the initial calculated mux_rate 
> is wildly overestimated
> Currently the patch defaults to VBR. I'd like to get some feedback 
> whether or not this is a good idea.

Just done preliminary tests with your patches and a set-top-box:

    - the VBR works but as bitrate increases, the box gets troubled by 
bursts (loss of picture updates)
    - the CBR works beautifully at all bitrates

Thanks a lot for this work !


More information about the ffmpeg-devel mailing list