Changes between Version 5 and Version 6 of x264EncodingGuide


Ignore:
Timestamp:
08/11/2012 08:36:51 AM (10 months ago)
Author:
rogerdpack
Comment:

flesh out what these mean...

Legend:

Unmodified
Added
Removed
Modified
  • x264EncodingGuide

    v5 v6  
    33x264 is a H.264/MPEG-4 AVC encoder. The goal of this guide is to inform new users how to create a high-quality H.264 video. 
    44 
    5 First you must choose your ratecontrol. A ratecontrol is a method that will decide how many bits will be used for each frame. This will determine the file size and how quality is distributed. There are two main methods that are useful for general users: Constant Rate Factor (CRF) and Two-Pass. Use CRF if you don't know what ratecontrol method to use. 
     5First you must choose your ratecontrol. A ratecontrol is a method that will decide how many bits will be used for each frame. This will determine the file size and also how quality is distributed.  
    66 
    7 If you need help compiling and installing see one of our [wiki:CompilationGuide FFmpeg and x264 compiling guides]. 
     7There are two most popular methods that are useful for general use: Constant Rate Factor (CRF) and Two-Pass Encoding. Use CRF if you don't know what ratecontrol method to use. 
     8 
     9CRF is basically a "keep this same constant quality always" setting.  0 is considered lossless, 51 is worst quality.  You can either set this value, or set a bit rate with one of the other methods, not both.  This is easy to use for beginners--just figure out how much quality you want, then record using this setting. 
     10 
     11The default is ABR (Average Bit Rate).  Like 
     12{{{ 
     13ffmpeg -i input -vcodec libx264 -b 1000k ... 
     14}}} 
     15 
     16This is something of a "running average" that allows for swings above and below this number, with the end goal that the final file will match this number "on average" (so basically, if it gets a lot of black frames, which cost very little, the next few seconds of non-black frames it will encode at very high quality, to bring the average back in line).  Using 2-pass can help this method to be more effective.  You can also use this in combination with a "max bit rate" setting in order to prevent some of the swing. 
     17 
     18You can "fake" a Constant Bit Rate setting by tuning the parameters of the ABR, like 
     19{{{ 
     20ffmpeg -i myfile.avi -vcodec libx264 -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v 
     21}}} 
     22 
     23bufsize is the "rate control buffer" so it will keep that "average" (4000k in this case) across every block of 1835k. 
     24 
     25Of course, if it's all just empty/black frames then it will still serve less than that many bits/s (but it will raise the quality level as much as it can to try to satisfy the requested parameters). 
     26 
     27If you need help compiling and installing libx264 see one of our [wiki:CompilationGuide FFmpeg and x264 compiling guides]. 
    828 
    929== Constant Rate Factor (CRF) == 
     
    1333The range is 0-51 where 0 is lossless, 23 is default, and 51 is worst possible. A lower value is a higher quality and a subjectively sane range is 18-28. Consider 18 to be visually lossless: it should look the same as the input but it isn't technically lossless. Increasing the CRF value +6 is roughly half the bitrate while -6 is roughly twice the bitrate. General usage is to choose the highest quality that still provides an acceptable quality. If the output looks good then try a higher value and if it looks bad then choose a lower value. 
    1434 
    15   '''Note:''' These CRF values apply to 8-bit x264 (the typical). 
     35  '''Note:''' The CRF values mentioned apply to 8-bit x264 (the typical). 
    1636 
    1737=== 2. Choose a preset === 
     
    7898}}} 
    7999 
     100or  
     101{{{ 
     102-x264opts vbv-bufsize=3600:vbv-maxrate=1800:crf=23 
     103}}} 
     104though these are somewhat redundant to other "standard" ffmepg settings, and can also be specified each separately. 
     105 
    80106---- 
    81107