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

Stratford, Alan Alan.Stratford
Mon Sep 7 18:05:04 CEST 2009


>On 09/04/2009 07:28 AM, Niobos wrote:
>>>> * Changed the calculation of total_bit_rate to be more accurate
>> This still had a bug in it (bits vs bytes thing), which is corrected
in
>> the attached version
>>
>>
>> On 03 Sep 2009, at 12:13, Alexandre Ferrieux wrote:
>>> 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 !
>>
>> I run my tests in VLC and on iPhone, both work without a glitch;
>> bitrates range from 200kbps to 1.5Mbps.
>
>
>Thanks a lot for the work, I'll review ASAP.
>

Hi,

Many thanks for this latest patch. This seems to help make TS files 
created by ffmpeg more compatible with VLC.

I have been looking at the calculation of total_bit_rate in the latest
update to this patch. I think that I understand the calculation but I am
confused by the line

total_bit_rate +=
  4 * total_bit_rate / (TS_PACKET_SIZE-4)   + /* TS  header size */
  1000 * 8 * sdt_size             / SDT_RETRANS_TIME    + /* SDT size */
  1000 * 8 * pat_pmt_size         / PAT_RETRANS_TIME    + /* PAT+PMT
size */
  1000 * 8 * 8                    / PCR_RETRANS_TIME;      /* PCR size
*/

It is the following part that is causing confusion:

  4 * total_bit_rate / (TS_PACKET_SIZE-4)   + /* TS  header size */

I believe that this is trying to adjust the total_bit_rate to allow for
the 
fact that the stream will be sent as TS packets, and, therefore, will 
require an extra 4 bytes of data for each 184 bytes in the stream. If
this is not the case then please ignore the rest of this post, but I
would greatly appreciate an explanation of what the line does.

If my understanding is correct this part should be:

  total_bit_rate * TS_PACKET_SIZE / (TS_PACKET_SIZE-4) + /*TS header
size*/

i.e. multiply the stream size by 188/184 to account for 4 extra bytes
every
TS packet.

Alan

--------------------------------------------------------------------------
Rosemount Aerospace Limited.
Registered Office: Stratford Road, Solihull, West Midlands, B90 4LA.
Registered in England No. 02849033.
--------------------------------------------------------------------------



More information about the ffmpeg-devel mailing list