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

Alexandre Ferrieux alexandre.ferrieux
Mon Oct 19 14:13:21 CEST 2009

Niobos wrote:
> On 19 Oct 2009, at 09:50, Alexandre FERRIEUX - FT/RD/SIRP/ASF/SOFTL wrote:
>> Niobos wrote:
>>> On 16 Oct 2009, at 15:37, Alexandre Ferrieux wrote:
>>>> Now I observed a regression wrt your previous patches: when muxing an
>>>> audio-only TS, the PCR is wrong by a large factor (between 4 and 6 
>>>> times
>>>> too slow). When muxing video only or both, it is correct.
>> >
>>> Can you provide me with:
>>> * The command line you used
>> ffmpeg.r20212vbr -i file.wav -vn -ar 44100 file.ts
>>> * The characteristics of the input file (especially number of 
>>> channels, since there is a filed bug about this)
>> I've done this with both mono and stereo wav files, same result.
>> Below are the details with one of each kind. On these small files the 
>> PCR bug is even stronger (a ratio nearing 9).
> I reviewed the differences between (my) version 3 and 4 of the patch and 
> found the source of the difference, which is a factor 10.
> However, I think the _new_ version is correct, while the old version was 
> "too slow". Although it should happen equally with Video and Audio+video...

Well, one fact is that the old one plays perfectly in hardware decoders, the new one doesn't !

Also, look at the delta-PCR values I provided: can you tell me which ones make sense given the original sound's duration ?

    Stereo sound, 4.86s:

      ab.20212.ts: delta PCR == 19890
      ab.19754.ts: delta PCR == 182975

    Mono sound, 6.12s:

      a.20212.ts: delta PCR == 25090
      a.19754.ts: delta PCR == 233610

(these "delta" are just the difference between the high 33 bits of PCR in first and last packet with adaptation field.)

>> v4:
>> [mpegts @ 0x8ddba80]calculated bitrate 104114bps, muxrate 1041140bps, 
>> sdt every 34, pat/pmt every 6 pkts
>> v3:
>> [mpegts @ 0x9940aa0]calculated bitrate 104044bps, muxrate 1040440bps, 
>> sdt every 345, pat/pmt every 69 pkts
> This also illustrates that factor 10: PAT is inserted every 100ms; which 
> is calculated correctly in the new version (86ms in this case), but not 
> in the old version (996ms). The PCR is calculated in the exact same way 
> and I didn't change the rest of the code in this patch.
> Could you try this regression between the unpatched ffmpeg and the 
> version 4?

Yes. Results below (20212 == unpatched) for the stereo file (ab) above:

      ab.20212.ts:    delta PCR == 342432 -> very jerky
      ab.20212vbr.ts: delta PCR == 19890  -> no sound
      ab.19754vbr.ts: delta PCR == 182975 -> perfect


More information about the ffmpeg-devel mailing list