[Ffmpeg-devel] [PATCH] fix (?) 2pass convergence errors

Michael Niedermayer michaelni
Mon Sep 4 11:03:27 CEST 2006


Hi

On Sun, Sep 03, 2006 at 10:12:42AM -0700, Corey Hickey wrote:
> Michael Niedermayer wrote:
> >>>> The attached patch should, I think, fix the recent errors we've been
> >>>> having with "Error: 2pass curve failed to converge". I've tested with
> >>>> mencoder and ffmpeg and I haven't seen anything wrong.
> >>>>
> >>>> Does this look ok to apply?
> >>>>
> >>> Is there some reason why you are using NULL context in av_log() calls?
> >> I didn't think the context was necessary for those particular messages.
> >> If it is, somebody should tell me.
> > 
> > of course should they have a context, think of a multithreded app which
> > encodes more then 1 file at the same time
> 
> Ok, I changed that. I also changed the "requested bitrate: " message to
> AV_LOG_DEBUG.
> 
> -Corey

may i suggest a slight modification to the convergence analysis ...

replace
    if(expected_bits > all_available_bits) rate_factor-= step;
by
int toobig=0
    ...
    if(expected_bits > all_available_bits){
        rate_factor-= step;
        toobig++;
    }

and then

assert(toobig<=40);
<some debuging av_log which prints expected bitrate, wanted bitrate, avg-qp, ...>
if(toobig==0){
    av_log(s->avctx, AV_LOG_INFO,
           "[lavc ratecontrol] Using all of requested bitrate is not "
           "possible for this video with these parameters. (try decreasing qmin)\n");
}else if(toobig==40){
    av_log(s->avctx, AV_LOG_ERROR,
           "[lavc ratecontrol] Error: bitrate too low for this video with "
           "these parameters.\n");
    return -1;
}else if(fabs(expected_bits/all_available_bits - 1.0) > 0.01){
    av_log(s->avctx, AV_LOG_ERROR, "[lavc ratecontrol] 2pass curve failed to converge\n");
    return -1;
}


PS: the step_mult stuff from x264 ratecontrol.c should be ported assuming
they (loren?) doesnt mind relicensing the few related lines under LGPL of
course ...

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list