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

Baptiste Coudurier baptiste.coudurier
Sat Sep 26 23:13:28 CEST 2009


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.

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



More information about the ffmpeg-devel mailing list