[FFmpeg-devel] [PATCH] Fix ratecontrol bug when time_base.num > 1
michaelni at gmx.at
Fri Nov 16 15:59:22 CET 2012
On Fri, Nov 16, 2012 at 02:34:54PM +0000, Joseph Artsimovich wrote:
> On 16/11/2012 13:59, Michael Niedermayer wrote:
> >On Fri, Nov 16, 2012 at 12:01:11PM +0000, Joseph Artsimovich wrote:
> >>When encoding long-GOP MPEG2 with time_base of 24/600 (with reduces
> >>to 1/25, but I need it for compatibility with some proprietary
> >>software) I noticed blow up of encoded frame size and "rc buffer
> >>underflow" errors. I traced it back to the following line in
> >>wanted_bits = (uint64_t)(s->bit_rate*(double)dts_pic->f.pts / fps);
> >>which doesn't take pts units into account.
> >>A patch is attached.
> >>@@ -708,7 +708,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
> >> if (!dts_pic || dts_pic->f.pts == AV_NOPTS_VALUE)
> >> wanted_bits= (uint64_t)(s->bit_rate*(double)picture_number/fps);
> >> else
> >>- wanted_bits = (uint64_t)(s->bit_rate*(double)dts_pic->f.pts / fps);
> >>+ wanted_bits = (uint64_t)(s->bit_rate*(double)dts_pic->f.pts / (fps*(double)s->dts_delta));
> >> }
> >dts_delta is only set in some cases and only based
> >on the first frames.
> >The durations of later frames can be entirely different from the
> >first frames.
> What's the proper way of doing it then? I initially tried to use
> s->avctx->time_base.num, but found that my 24/600 time_base was
> reduced to 1/25.
I dont fully understand the problem, so its hard to suggest how to
If the timebase is 1/25, then pts should count 1,2,3,4... and fps
should be 25 and it all should work but obviuosuly it doesnt
so can you elaborate why its failing ?
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Observe your enemies, for they first find out your faults. -- Antisthenes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: Digital signature
More information about the ffmpeg-devel