[Ffmpeg-devel] [BUG] Error: 2pass curve failed to converge
Sven Over
svenover
Wed Aug 9 11:44:44 CEST 2006
Am Friday 04 August 2006 00:45 schrieb Corey Hickey:
> > [mpeg4 @ 0xc840d0]Error: 2pass curve failed to converge
[...]
> Can anybody fix this? The problem gets reported somewhat regularly on
> the mplayer/mencoder user lists. If I could fix it myself I would, but
> the bug is out of my league...
>
> I don't want to advocate reverting r5422, since doing so would only mask
> the bug, but functionally it would still be an improvement over what has
> been happening.
Hello.
I yesterday encountered the "2pass curve failed to converge" problem
yesterday, when recoding DVB recorded material with a 528x768 resolution to a
PAL-DVD compliant 720x768 resolution. Since I have plenty of space on the DVD
and the original material has already poor quality (video bitrates around
2000kbit/s are quite usual), I want to do whatever I can in order not to
degrade the quality even more. Therefore I use 2pass encoding and increase
the bitrate for the recoding process, depending on how much space I have on
the DVD. It turns out that sometimes I can increase the video bitrate by 70%
or so.
In this scenario, I find it quite natural, that ffmpeg cannot spend all the
bits I offer. There is simply not enough information in the original video
material that it can be encoded in such high bitrates. I guess reencoding
with a 70% higher bitrate is a ridiculous idea itself. Anyway, in this case I
don't want ffmpeg to exit with an error. Instead it should just use as many
bits as needed, and so the resulting file will be smaller than calculated,
but is of optimal quality.
In order to have it like this, I changed the relevant part in ratecontrol.c
(compare 'r5422') like so:
if(fabs(expected_bits/all_available_bits - 1.0) > 0.01 ){
if (expected_bits<all_available_bits){
const double percent_too_low=(1.-(expected_bits/all_available_bits))*100.;
av_log(s->avctx, AV_LOG_INFO, "INFO: 2pass curve failed to converge
(expected_bits %.1f%% too low)\n",
percent_too_low );
}else{
const double
percent_too_high=((expected_bits/all_available_bits)-1.)*100.;
av_log(s->avctx, AV_LOG_ERROR, "ERROR: 2pass curve failed to converge
(expected_bits %.1f%% too high)\n",
percent_too_high);
return -1;
}
}
This way, the "2pass curve failed" is only an INFO, when the outcome will be
too small. It stays an ERROR, when ffmpeg is unable to fit the video into the
requested number of bits. Too gain some experience, the log messages also
contain also the magnitude of the mismatch in percent.
To come back to my application, I think I might also use 1pass encoding
instead of 2pass, whenever I am increasing the bitrate more than, say, 30%.
With so much extra-bitrate, the results should be optimal in the first pass.
Bye,
Sven.
--
Sven Over
Stephanienstr. 9
76133 Karlsruhe
GERMANY
Telefon: 0721-9204199
http://www.svenover.de/
More information about the ffmpeg-devel
mailing list