[FFmpeg-devel] [PATCH] Calculate and store mov bitrate

Baptiste Coudurier baptiste.coudurier
Fri Oct 9 21:57:12 CEST 2009


Hi,

On 10/6/09 11:21 PM, haim alon wrote:
> Hi,
>
> On Sat, Sep 26, 2009 at 11:13 PM, Baptiste Coudurier<
> baptiste.coudurier at gmail.com>  wrote:
>
>> Hi,
>>
>> On 08/20/2009 06:47 AM, haim alon wrote:
>>
>>> Hi,
>>> This patch calculates the actual bitrate of a mov file and stores it in
>>> the
>>> AVCodecContext structure.
>>> Regards
>>> Haim.
>>>
>>>
>>> ffmpeg.bitrate.patch
>>>
>>>
>>> Index: libavformat/mov.c
>>> ===================================================================
>>> --- libavformat/mov.c   (revision 19667)
>>> +++ libavformat/mov.c   (working copy)
>>> @@ -1399,6 +1399,8 @@
>>>       unsigned int stss_index = 0;
>>>       unsigned int stps_index = 0;
>>>       unsigned int i, j;
>>> +    int64_t stream_size = 0;
>>> +    double duration;
>>>
>>> [...]
>>>
>>>
>>
>>> @@ -1468,6 +1471,8 @@
>>>                   }
>>>               }
>>>           }
>>> +        duration = (st->duration/(double)mov->time_scale);
>>> +        st->codec->bit_rate = (stream_size*8.0)/duration;
>>>
>>
>> You don't need a duration variable and mov->time_scale is wrong.
>>
>>
> Can you recommend any alternative way to get the stream duration (in
> seconds) ?

You must use st->duration and sc->time_scale, not mov->time_scale.

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



More information about the ffmpeg-devel mailing list