[Ffmpeg-devel] [PATCH] tunable vb_strategy=1

Corey Hickey bugfood-ml
Tue May 30 03:47:11 CEST 2006


In general, using a small number of B-frames produces a slightly
higher-quality encode. Scenes with very high amounts of motion often
suffer, though. Lavc has two strategies for removing B-frames where they
will hurt quality.

vb_strategy=1 avoids B-frames in high-motion areas, which makes them
look better, but it drops so many B-frames that a large portion of the
quality gain is nullified. The resulting PSNR is much lower, and the
difference shows.

vb_strategy=2 tries several different combinations of B-frames and picks
the one that yields the best quality. The results look very good and the
PSNR is even a little bit higher. Trouble is, the first pass takes much
longer.


It seems to me that vb_strategy=1 is fundamentally a good idea, but it's
too sensitive. I looked in the code and found a number: 40. If that
number were lower, lavc would use more B-frames. I made it tunable and
ran some tests. All results are for the second pass (except first-pass
encoding time), and each test had vmax_b_frames=2.


key:
-------------------------------------------------
n      the b_sensitivity value with vb_strategy=1
psnr   PSNR
%I     percentage of I-frames
%P                   P-frames
%B                   B-frames
q      average quantizer of all frames
qI                          I-frames
qP                          P-frames
qB                          B-frames
t1     seconds of encoding time for pass 1
t2                                       2

vb_strategy=1:b_sensitivity=n
 n   psnr  %I  %P  %B      q    qI    qP    qB    t1   t2
---------------------------------------------------------
 1  42.95   2  31  66   4.75  2.89  3.18  5.55   228  387
 5  42.92   2  41  56   4.74  3.15  3.44  5.74   218  363
10  42.90   1  47  50   4.71  3.35  3.61  5.81   213  350
15  42.88   1  51  47   4.70  3.26  3.68  5.86   211  344
20  42.86   1  53  44   4.68  3.44  3.73  5.88   210  340
25  42.85   1  55  42   4.66  3.31  3.76  5.88   208  336
30  42.84   1  56  41   4.65  3.35  3.79  5.90   207  335
35  42.84   1  58  39   4.63  3.42  3.80  5.89   206  332
40  42.83   2  58  39   4.63  3.38  3.82  5.91   206  338  *default*
45  42.82   1  60  37   4.62  3.37  3.84  5.92   209  336
50  42.82   2  61  36   4.60  3.52  3.86  5.92   209  332
55  42.82   2  61  36   4.60  3.52  3.87  5.91   208  334
60  42.82   2  62  35   4.60  3.56  3.88  5.92   208  334
65  42.81   2  63  34   4.59  3.44  3.89  5.92   207  327
70  42.81   2  63  34   4.58  3.67  3.90  5.92   204  326
75  42.81   2  63  34   4.58  3.67  3.90  5.92   204  324
80  42.80   2  64  33   4.58  3.57  3.92  5.92   204  322


For comparison, here are the values for vb_strategy=0 and 2.

vmax_b_frames=2:vb_strategy=0
    42.95   2  31  66   4.75  2.89  3.18  5.55   221  386

vmax_b_frames=2:vb_strategy=2
    42.97   2  43  54   4.62  3.07  3.44  5.63   791  362


As you can see, I wasn't able to work any miracles with the PSNR -- it
still drops off. Visually, though, the results are pretty good: with a
b_sensitivity as low as 5 or 10, high-motion scenes end up looking
nearly as good as they do with vb_strategy=2, and the PSNR loss is
minimal. I can still tell that vb_strategy=2 looks a tiny bit better
overall, but there's very little difference.

Even with fairly low values of b_sensitivity, the encoding time is a bit
better than with vb_strategy=0, and, of course, much better than
vb_strategy=2.

-Corey
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: b_sensitivity.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20060529/17fb13ec/attachment.txt>



More information about the ffmpeg-devel mailing list