[FFmpeg-devel] [PATCH] mpegtsenc: Force writing PCR-only packet to PCR stream if the current stream is not the PCR stream

Baptiste Coudurier baptiste.coudurier
Thu Oct 14 07:50:23 CEST 2010


On 10/13/10 10:37 PM, Tomas H?rdin wrote:
> On Thu, 2010-10-07 at 13:29 +0200, Tomas H?rdin wrote:
>> On Wed, 2010-10-06 at 15:10 -0700, Baptiste Coudurier wrote:
>>> On 10/06/2010 04:33 AM, Tomas H?rdin wrote:
>>>> ...
>>>>
>>>> When writing non-video streams PCR still needs to be written
>>>> periodically, but PCR may only be written for streams whose PID matches
>>>> a service's PCR PID (typically the first video stream). The patch uses a
>>>> simple solution for this: write a PCR-only packet with the video
>>>> stream's PID, similarly to how such packets are written when padding for
>>>> CBR mode. This is of course a bit wasteful when muxing VBR, but it is
>>>> more correct AFAICT.
>>>
>>> I agree, although the perfect solution would be write PCR based on 
>>> timing. Specifications says that delta between PCRs shall be <= 0.1s
>>>
>>>> ...
>>>>
>>>> A better solution would of course be to interleave the PES packets that
>>>> make up the last few packets of each stream of each service, and make
>>>> sure PCR is written for all services when required. At the moment I am
>>>> more concerned with the muxer outputting a compliant bitstream though,
>>>> rather than being the most efficient implementation.
>>>
>>> I agree with that.
>>
>> Hopefully I'll be given time later to improve the muxer. I have some
>> ideas how this could be done without being too complicated.
>>
>>>> [...]
>>>  >
>>>> +
>>>> +        if(write_pcr&&  ts_st->pid != ts_st->service->pcr_pid) {
>>>> +            /* write a pcr-only packet to the pcr stream since pcr needs to be
>>>> +             * written but the current stream is not the pcr stream
>>>> +             * FIXME: this is slightly wasteful in VBR mode */
>>>
>>> Please no new FIXME, you can check wether you are in VBR mode or not.
>>
>> Shouldn't PCR be written either way, even if doing VBR? Perhaps it
>> should say NOTE instead of FIXME, or nothing at all. Attached patch
>> simply removes it.

It will increase overhead like you said, and ts has already much
overhead. When muxing in VBR mode, the clock is the timestamps.
You just have to ensure that two packets timestamps do not have > 0.1s
difference. This could happen for frame rates < 10 fps or when variable
frame rate is used.

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list