[x264-devel] Making sense out of x264 rate control methods

Jason Garrett-Glaser darkshikari at gmail.com
Mon Feb 22 10:00:41 CET 2010

>    CBR one pass mode
>      - Lowest quality (at least in my tests gives lowest SSIM 0.9815)
>      - Resulting bitrate was lower than the desired (975.80kbps)
>      e.g. x264 --vbv-bufsize 2000 --vbv-maxrate 1000 --bitrate 1000 -o <output> <input>

x264 does not currently add filler to pad to the full bitrate you
prefer.  In a zero motion scene, it will not throw away bits on
nothing.  When NAL HRD support is added (a week or two), --nal-hrd cbr
will make the stream exactly 1000kbps, to the last bit, through

>    CRF + VBV
>      - Second in quality (second largest SSIM 0.9818 in my tests)
>      - Resulting bitrate was even lower (960.16kbps). Maybe a lower CRF
>        would have given better SSIM and higher bitrate?? but...
>      - I have no idea how to select CRF value. Some forums say 18 is
>        the best bet.
>      e.g. x264 --vbv-bufsize 2000 --vbv-maxrate 1000 --crf 18 -o <output> <input>

CRF is the quality level.  18 is roughly visually transparent--which
is not what you want here.  The purpose of CRF + VBV is to stream with
a maximum bitrate, but to not waste bits where they aren't necessary.
At lower bitrates, you probably will not be perfectly transparent at
any point, so your target quality should be lower than that (higher

>  If I have time to spend and need to encode files for streaming then:
>    2 Pass Encode:
>     - Gives the highest SSIM 0.9822 in my tests
>     - Resulting bitrate is very close to the desired (1001.99 kbps)
>     - The slower one because of two pases.
>      e.g. x264 --pass 1 --bitrate 1000 -o <output> <input>
>          x264 --pass 2 --vbv-bufsize 2000 --vbv-maxrate 1000 --bitrate 1000 -o <output> <input>

The first pass should probably use CBR too.  Also note that 2-pass CBR
is not always better than one-pass CBR; they're generally close enough
that it it doesn't matter too much.

2-pass is better at using up all the bits though.

>    CRF with second pass CRF + VBV
>      - Just for testing but gave results similar so single pass CBR and
>        as slow as 2pass so better stick with 2pass encode.
>      e.g. x264 --pass 1 --crf 18 -o <output> <input>
>           x264 --pass 2 --vbv-bufsize 2000 --vbv-maxrate 1000 --crf 18 -o <output> <input>

--crf and --pass 2 will cause an error.  That commandline could not have worked.

>  - How the other hundred options of x264 can affect these results?

A lot.  Check the presets.

>  - How to select the CRF value to use for streaming or for storage?

Start with a low CRF value (say, 18).  Raise it one by one, encoding
your sample clip each time.  Stop when the quality has dropped too
much to be tolerable to you, and then lower it back to the last good
CRF.  Use this CRF for every video.

Dark Shikari

More information about the x264-devel mailing list