[FFmpeg-devel] [PATCH] Calculate and store mov bitrate.
Haim Alon
haim.alon
Sun Mar 8 16:21:26 CET 2009
On Thu, 2009-02-26 at 11:11 -0800, Baptiste Coudurier wrote:
> On 2/26/2009 7:17 AM, Haim Alon wrote:
> > Hi,
> >
> > This patch calculates and mov bitrate and stores it in AVCodecContext
> > structure.
> > Regards,
> > Haim.
> >
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > Index: libavformat/mov.c
> > ===================================================================
> > --- libavformat/mov.c (revision 17613)
> > +++ libavformat/mov.c (working copy)
> > @@ -1236,6 +1236,7 @@
> > unsigned int stsc_index = 0;
> > unsigned int stss_index = 0;
> > unsigned int i, j;
> > + int64_t stream_size = 0;
> >
> > /* adjust first dts according to edit list */
> > if (sc->time_offset) {
> > @@ -1279,6 +1280,7 @@
> > current_offset, current_dts, sample_size, distance, keyframe);
> > }
> > current_offset += sample_size;
> > + stream_size += sample_size;
> > assert(sc->stts_data[stts_index].duration % sc->time_rate == 0);
> > current_dts += sc->stts_data[stts_index].duration / sc->time_rate;
> > distance++;
> > @@ -1290,6 +1292,8 @@
> > }
> > }
> > }
> > + double duration = (mov->duration/(double)mov->time_scale);
> > + st->codec->bit_rate = (stream_size*8.0)/duration;
>
> This is wrong, stream duration must be used, not mov->duration.
>
You are right. It should be st->duration instead of mov->duration.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg.bitrate.patch
Type: text/x-patch
Size: 1190 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090308/90a3b9d2/attachment.bin>
More information about the ffmpeg-devel
mailing list