Changes between Version 46 and Version 47 of Encode/H.264


Ignore:
Timestamp:
Oct 26, 2013, 12:04:26 AM (5 years ago)
Author:
llogan
Comment:

High 4.1 and lower work fine in QT 10.2 (did not test older versions); add Additional Resources; cleanup

Legend:

Unmodified
Added
Removed
Modified
  • Encode/H.264

    v46 v47  
    1010 
    1111== Constant Rate Factor (CRF) ==#crf 
     12 
    1213This 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. 
    1314 
     
    2021 
    2122=== 2. Choose a preset === 
     23 
    2224A 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. 
    2325 
     
    3739 
    3840=== 3. Use your settings === 
     41 
    3942Once 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. 
    4043 
     
    5053 
    5154== Two-Pass ==#twopass 
     55 
    5256This method is generally used if you are targeting a specific output file size and output quality from frame to frame is of less importance. This is best explained with an example. Your video is 10 minutes (600 seconds) long and an output of 50 MB is desired. Since `bitrate = file size / duration`: 
    5357 
     
    7377 
    7478== Lossless H.264 == 
     79 
    7580You can use `-qp 0` or `-crf 0` to encode a lossless output. Use of `-qp` is recommended over `-crf` for lossless because 8-bit and 10-bit x264 use different `-crf` values for lossless.  Two useful presets for this are `ultrafast` or `veryslow` since either a fast encoding speed or best compression are usually the most important factors. Most non-FFmpeg based players will not be able to decode lossless (but !YouTube can), so if compatibility is an issue you should not use lossless. 
    7681 
     
    114119=== CBR (Constant Bit Rate) === 
    115120 
    116 There is no native CBR mode, but you can "simulate" a constant bit rate setting by tuning the parameters of ABR, like 
     121There is no native CBR mode, but you can "simulate" a constant bit rate setting by tuning the parameters of ABR: 
     122 
    117123{{{ 
    118124ffmpeg -i input -c:v libx264 -b:v 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v 
    119125}}} 
    120126 
    121 in this example, `-bufsize` is the "rate control buffer" so it will enforce your requested "average" (4000k in this case) across each 1835k worth of video.  So basically it is assumed that the receiver/end player will buffer that much data so it's ok to fluctuate within that much. 
    122  
    123 Of 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, up to the crf level). 
     127In the above example, `-bufsize` is the "rate control buffer" so it will enforce your requested "average" (4000k in this case) across each 1835k worth of video.  So basically it is assumed that the receiver/end player will buffer that much data so it's ok to fluctuate within that much. 
     128 
     129Of 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, up to the crf level. 
    124130 
    125131=== CRF with maximum bit rate === 
     
    138144=== Compatibility === 
    139145 
    140 If 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: 
    141 {{{ 
    142 -profile:v baseline 
    143 }}} 
    144 This disables some advanced features but provides for better compatibility. Typically you may not need this setting, but if you do use this setting it may increase the bit rate quite a bit compared to what is needed to achieve the same quality in higher profiles. 
     146==== All devices ==== 
     147 
     148If you want your videos to have highest compatibility with target devices (older iOS versions or all Android devices): 
     149 
     150{{{ 
     151-profile:v baseline -level 3.0 
     152}}} 
     153 
     154This disables some advanced features but provides for better compatibility. Typically you may not need this setting (and therefore avoid using `-profile:v` and `-level`), but if you do use this setting it may increase the bit rate quite a bit compared to what is needed to achieve the same quality in higher profiles. 
     155 
     156==== iOS ==== 
    145157 
    146158||||||||= '''iOS Compatability''' ([https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/UsingHTTPLiveStreaming/UsingHTTPLiveStreaming.html#//apple_ref/doc/uid/TP40008332-CH102-SW8 source]) =|| 
     
    153165|| High || 4.1 || iPad 2 and later and iPhone 4S and later || `-profile:v high -level 4.1` || 
    154166 
    155 For a list of supported profiles and their descriptions see: 
    156 {{{ 
    157 x264 --fullhelp 
    158 }}} 
    159  
    160 Keep in mind that Apple !QuickTime only supports YUV 420 color space for x264 encoded movies, and does not support anything higher than the "main" profile. This leaves only 2 options for !QuickTime compatible clips: baseline and main. All of the other profiles are currently not supported with !QuickTime, although they will play back in pretty much any other player. 
    161  
    162 {{{#!comment 
    163 Has anyone tested this recently? It seems oddly stupid, even for QT not to support main. 
    164 }}} 
     167This table does not include any additional restrictions which may be present. 
     168 
     169==== Apple Quicktime ==== 
     170 
     171Apple !QuickTime only supports YUV planar color space with 4:2:0 chroma subsampling (use `-pix_fmt yuv420p`) for H.264 video. For information on additional restrictions see [http://mewiki.project357.com/wiki/X264_Encoding_Suggestions#QuickTime-compatible_Encoding QuickTime-compatible Encoding]. 
     172 
     173==== Blu-ray ==== 
     174 
     175See [http://www.x264bluray.com/ Authoring a professional Blu-ray Disc with x264]. 
    165176 
    166177=== Pre-testing your settings === 
     178 
    167179Encode a random section instead of the whole video with the `-ss` and `-t` options to quickly get a general idea of what the output will look like. 
    168180* `-ss`: Offset time from beginning. Value can be in seconds or HH:MM:SS format. 
     
    186198=== Why doesn't my lossless output look lossless? === 
    187199 
    188 Blame the rgb->yuv conversion. If you convert to yuv444, it should still be lossless (which is the default now). 
     200Blame the RGB to YUV color space conversion. If you convert to yuv444 it should still be lossless (which is the default now). 
    189201 
    190202=== Will a graphics card make x264 encode faster? === 
     
    194206=== Encoding for dumb players === 
    195207 
    196 You may need to use `-pix_fmt yuv420p` for your output to work in !QuickTime and most other players. These players only supports YUV 420 color space for H.264 encoded clips. Otherwise, depending on your source, ffmpeg may output to a pixel format that may be incompatible with these players. 
     208You may need to use `-pix_fmt yuv420p` for your output to work in !QuickTime and most other players. These players only supports the YUV planar color space with 4:2:0 chroma subsampling for H.264 video. Otherwise, depending on your source, ffmpeg may output to a pixel format that may be incompatible with these players. 
     209 
     210---- 
     211 
     212== Additional Resources == 
     213 
     214* [http://mewiki.project357.com/wiki/X264_Settings x264 Settings - MeWiki] 
     215* [http://mewiki.project357.com/wiki/X264_Encoding_Suggestions x264 Encoding Suggestions - MeWiki]