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

Horacio Sanson horacio.sanson at gmail.com
Fri Feb 19 09:59:11 CET 2010


On Wed, Feb 17, 2010 at 07:53:06PM -0800, Jason Garrett-Glaser wrote:
> >  ABR Mode
> >   - Tries to keep the encoded media around the desired bitrate. No
> >     guarantees.
> >   - To enable in x264 simply set bitrate parameter.
> >   - qp_min, qp_max and qp_step can be used to control the
> >     quality of ABR mode?
> >   - qp, ipratio and pbratio are ignored in ABR mode?
> >   - Good for generating the first pass log file that can be used for
> >     subsequent VBR or CBR second passes.
> >
> >     x264 --bitrate 1500 -o <output> <input>
> 
> ipratio applies to all modes.  pbratio applies to all modes whenever
> MB-tree is disabled.
> 
> >  VBR Mode
> >   - By running ABR mode two or more passes we automatically get VBR
> >     mode.
> >   - Does a better job at keeping the media around the desired bitrate
> >     than ABR but takes longer encoding time
> >   - Good for generating second and subsequent log pass files. Run as
> >     many times as desired but after 3 passes quality improvements are
> >     negligible.
> >
> >     x264 --pass 1 --bitrate 1500 -o <output> <input>  # ABR Mode
> >     x264 --pass 2 --bitrate 1500 -o <output> <input>  # VBR Mode
> 
> This is called 2-pass mode, not VBR mode.  ABR is a form of VBR.  CRF
> is also a form of VBR.  In fact, anything not CBR is a form of VBR.
> 

  Thanks, this clears out a lot of things. Anyone comparing ABR with VBR
  or CRF with VBR has no idea what he is talking about.
  
> After 2 passes the quality change is negligable, not 3.
> 
> It doesn't necessarily take a longer time, since you can use faster
> settings to compensate (and may still get better results than 1-pass
> ABR).  In general, never use ABR mode, ever.
> 
  I always use the turbo option of mencoder when encoding in x264. It
  really speeds up the first pass.

> >  CBR Mode
> >   - By running ABR mode and setting vbv_maxrate equal to bitrate we get
> >     CBR mode.
> >   - The hard limit in maxrate can cause high degradation in quality.
> >     Only use if you really need to limit the bitrate below a certain
> >     value.
> >   - Not useful to generate first pass log files.
> >
> >     x264 --vbv-bufsize 2000 --bitrate 1000 -o <output> <input>
> 
> CBR is perfectly useful to generate first pass log files for a 2-pass
> CBR encode.  2-pass generally doesn't help much with CBR though and
> can sometimes hurt.
> 
> > For single pass encodings I should use use CQP, ABR, CBR, CRF or Lossless.
> 
> No, you shouldn't use ABR ever.
> 

  Understood.

> >  - ABR if you care about bitrate (e.g. streaming)
> 
> ABR is useless for streaming.  For streaming, the best option is
> capped CRF (CRF + VBV) or CBR.
>
> >  - CRF if you care about quality and bitrate/size is irrelevant.
> 
> No, CRF if you care about quality and you don't need a _specific
> average bitrate_.  You can still cap the local bitrate using VBV.
> 

Just to wrap this up:

  If I am in a hurry and need to encode files for streaming I can use:

    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>

    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>

  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>

    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>

  If I only care about quality and bitrate/storage/time are no problem then
  CRF is the way to go:.

     - With CRF 18.0 gives very high SSIM 0.9900 but bitrate is
       2019.07kbps.
     - With CRF 23.0 gives SSIM 0.9835 and bitrate 960.46kbps


Open questions:

  - How the other hundred options of x264 can affect these results?
    
  - How to select the CRF value to use for streaming or for storage?


> Dark Shikari
> _______________________________________________
> x264-devel mailing list
> x264-devel at videolan.org
> http://mailman.videolan.org/listinfo/x264-devel

-- 
regards,
Horacio Sanson


More information about the x264-devel mailing list