Changes between Version 40 and Version 41 of Encode/H.264


Ignore:
Timestamp:
Feb 23, 2013, 5:17:01 PM (5 years ago)
Author:
slhck
Comment:

use c:v for syntax, actually you don't need an option value at all ("help" doesn't exist and will throw the same error)

Legend:

Unmodified
Added
Removed
Modified
  • Encode/H.264

    v40 v41  
    55x264 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. 
    66 
    7 There are two ratecontrol modes that are usually suggested for general use: [#crf Constant Rate Factor (CRF)] or [#twopass Two-Pass ABR]. The 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. 
     7There are two rate control modes that are usually suggested for general use: [#crf Constant Rate Factor (CRF)] or [#twopass Two-Pass ABR]. The rate control 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. 
    88 
    99If you need help compiling and installing libx264 see one of our [wiki:CompilationGuide FFmpeg and x264 compiling guides]. 
    1010 
    1111== Constant Rate Factor (CRF) ==#crf 
    12 This method allows the encoder to attempt to achieve a certain output quality for the whole file when output file size is of less importance. This provides maximum compression effectiveness with a single pass and each frame gets the bitrate it needs to keep the requested quality level. The downsides is that you can't tell it to get a specific filesize or not go over a specific size or bitrate. 
     12This method allows the encoder to attempt to achieve a certain output quality for the whole file when output file size is of less importance. This provides maximum compression efficiency with a single pass. Each frame gets the bitrate it needs to keep the requested quality level. The downside is that you can't tell it to get a specific filesize or not go over a specific size or bitrate. 
    1313 
    1414=== 1. Choose a CRF value === 
    15 The range of the quantizer scale 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 or nearly 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. 
     15The range of the quantizer scale 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 or nearly the same as the input but it isn't technically lossless.  
     16 
     17Increasing the CRF value +6 is roughly half the bitrate while -6 is roughly twice the bitrate. General usage is to choose the highest CRF value 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. 
    1618 
    1719  '''Note:''' The CRF quantizer scale mentioned on this page only applies to 8-bit x264 (10-bit x264 quantizer scale is 0-63). You can see what you are using with `x264 --help` listed under `Output bit depth`. 8-bit is more common amongst distributors. 
    1820 
    1921=== 2. Choose a preset === 
    20 A preset is a collection of options that will provide a certain encoding speed to compression ratio. A slower preset will provide better compression (compression is quality per filesize). General usage is to use the slowest preset that you have patience for. Current presets in descending order of speed are: `ultrafast`, `superfast`, `veryfast`, `faster`, `fast`, `medium`, `slow`, `slower`, `veryslow`, `placebo`. Ignore `placebo` as it is a joke and a waste of time (see [#faq FAQ]). You can see a list of current presets with `-preset help`, and what settings they apply with `x264 --fullhelp`. 
     22A preset is a collection of options that will provide a certain encoding speed to compression ratio. A slower preset will provide better compression (compression is quality per filesize). This means that, for example, if you target a certain file size or constant bit rate, you will achieve better quality with a slower preset. Similarly, for constant quality encoding, you will simply save bitrate by choosing a slower preset. 
     23 
     24The general guideline is to use the slowest preset that you have patience for. Current presets in descending order of speed are: `ultrafast`,`superfast`, `veryfast`, `faster`, `fast`, `medium`, `slow`, `slower`, `veryslow`, `placebo`. The default preset is `medium`. Ignore `placebo` as it is not useful (see [#faq FAQ]). You can see a list of current presets with `-preset help`, and what settings they apply with `x264 --fullhelp`. 
    2125 
    2226You can optionally use `-tune` to change settings based upon the specifics of your input. Current tunings include: `film`, `animation`, `grain`, `stillimage`, `psnr`, `ssim`, `fastdecode`, `zerolatency`. For example, if your input is animation then use the `animation` tuning, or if you want to preserve grain then use the `grain` tuning. If you are unsure of what to use or your input does not match any of tunings then omit the `-tune` option. You can see a list of current tunings with `-tune help`, and what settings they apply with `x264 --fullhelp`. 
    2327 
    24 Another optional setting is `-profile:v` which will limit the output to a specific H.264 profile. This can generally be omitted unless the target device only supports a certain profile. Current profiles include: `baseline`, `main`, `high`, `high10`, `high422`, `high444`. Note that usage of `-profile:v` is incompatible with lossless encoding. 
     28Another optional setting is `-profile:v` which will limit the output to a specific H.264 profile. This can generally be omitted unless the target device only supports a certain profile (see [#compatibility Compatibility]). Current profiles include: `baseline`, `main`, `high`, `high10`, `high422`, `high444`. Note that usage of `-profile:v` is incompatible with lossless encoding. 
    2529 
    26 You can list all possible internal presets/tunes for your ffmpeg like  
     30As a shortcut, you can also list all possible internal presets/tunes for FFmpeg by specifying no preset or tune option at all: 
    2731 
    28 `$ ffmpeg -i some_file -vcodec libx264 -preset help -tune help dummy.avi` 
     32{{{ 
     33ffmpeg -i input -c:v libx264 -preset -tune dummy.mp4 
     34}}} 
    2935 
    3036=== 3. Use your settings === 
    31 Use these same settings for the rest of your videos if you are encoding more. This will ensure that they will all have similar quality. 
     37Once you've chosen your settings, apply them for the rest of your videos if you are encoding more. This will ensure that they will all have similar quality. 
    3238 
    3339=== CRF Example === 
     40 
     41The following example will encode a video with x264, using a slower than normal preset, with a slightly better quality than the default (23). 
    3442 
    3543{{{ 
    3644ffmpeg -i input -c:v libx264 -preset slow -crf 22 -c:a copy output.mkv 
    3745}}} 
     46 
     47Note that in this example, the audio stream of the input file is simply copied over to the output and not re-encoded. 
    3848 
    3949---- 
     
    126136libx264 offers a `-tune zerolatency` option. See the [[StreamingGuide]]. 
    127137 
    128 === Compatibility === 
     138=== Compatibility ===#compatibility 
    129139 
    130140If you want your videos to have highest compatibility with target players (for instance, with older iOS versions or all Android devices) then you'll want to specify