Changes between Version 45 and Version 46 of Encode/H.264
- Timestamp:
- Oct 23, 2013, 7:48:52 PM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Encode/H.264
v45 v46 13 13 14 14 === 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.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 or nearly so: it should look the same or nearly the same as the input but it isn't technically lossless. 16 16 17 Increasing 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.17 The range is exponential, so increasing 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. 18 18 19 '''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 among stdistributors.19 '''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 among distributors. 20 20 21 21 === 2. Choose a preset === … … 31 31 32 32 {{{ 33 ffmpeg - i input -c:v libx264 -preset -tune dummy.mp433 ffmpeg -y -i input -c:v libx264 -preset -tune -f mp4 /dev/null 34 34 }}} 35 35 36 '''Note:''' Windows users should use `NUL` instead of `/dev/null`. 37 36 38 === 3. Use your settings === 37 Once 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.39 Once 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. 38 40 39 41 === CRF Example === 40 41 The following example will encode a video with x264, using a slower than normal preset, with a slightly better quality than the default (23).42 42 43 43 {{{ … … 45 45 }}} 46 46 47 Note that in this example , the audio stream of the input file is simply copiedover to the output and not re-encoded.47 Note that in this example the audio stream of the input file is simply [http://ffmpeg.org/ffmpeg.html#Stream-copy stream copied] over to the output and not re-encoded. 48 48 49 49 ---- … … 73 73 74 74 == Lossless H.264 == 75 You 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 , so if compatibility is an issue you should not use lossless.75 You 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. 76 76 77 77 === Lossless Example (fastest encoding) === … … 107 107 108 108 {{{ 109 ffmpeg -i input -c:v libx264 -b:v 1000k ...109 ffmpeg -i input -c:v libx264 -b:v 1000k output.mp4 110 110 }}} 111 111 … … 127 127 You can also also use a crf with a maximum bit rate by specifying both crf *and* maxrate settings, like 128 128 {{{ 129 ffmpeg -i input -c:v libx264 -crf 20 -maxrate 400k -bufsize 1835k 129 ffmpeg -i input -c:v libx264 -crf 20 -maxrate 400k -bufsize 1835k output.mp4 130 130 }}} 131 131 … … 138 138 === Compatibility === 139 139 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 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 141 {{{ 142 142 -profile:v baseline 143 143 }}} 144 which disables some advanced features but provides for better compatibility. Typically you may not need this setting. Also if you do use this setting, it increases the bit rate quite a bit, compared to what's needed to achieve the same quality in higher profiles.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. 145 145 146 For a list of supported profiles and their description, run 146 ||||||||= '''iOS Compatability''' ([https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/UsingHTTPLiveStreaming/UsingHTTPLiveStreaming.html#//apple_ref/doc/uid/TP40008332-CH102-SW8 source]) =|| 147 ||= '''Profile''' =||= '''Level''' =||= '''Devices''' =||= '''Options''' =|| 148 || Baseline || 3.0 || All devices || `-profile:v baseline -level 3.0` || 149 || Baseline || 3.1 || iPhone 3G and later, iPod touch 2nd generation and later || `-profile:v baseline -level 3.1` || 150 || Main || 3.1 || iPad (all versions), Apple TV 2 and later, iPhone 4 and later || `-profile:v main -level 3.1` || 151 || Main || 4.0 || Apple TV 3 and later, iPad 2 and later, iPhone 4S and later || `-profile:v main -level 4.0` || 152 || High || 4.0 || Apple TV 3 and later, iPad 2 and later, iPhone 4S and later || `-profile:v high -level 4.0` || 153 || High || 4.1 || iPad 2 and later and iPhone 4S and later || `-profile:v high -level 4.1` || 154 155 For a list of supported profiles and their descriptions see: 147 156 {{{ 148 157 x264 --fullhelp 149 158 }}} 150 159 151 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. 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 }}} 152 165 153 166 === Pre-testing your settings === … … 177 190 === Will a graphics card make x264 encode faster? === 178 191 179 No . libx264 doesn't use them (at least not yet). There are some proprietary encoders that utilize the GPU, but that does not mean they are well optimized, though encoding time may be faster; and they might be [http://phoronix.com/forums/showthread.php?50697-Test-tool-for-snb-h264-encoder-in-libva-git&p=205580#post205580 worse than x264] anyway, and possibly slower. Regardless, FFmpeg today doesn't support any means of gpuencoding, outside of libx264.192 Not necessarily. [http://git.videolan.org/?p=x264.git;a=commit;h=3a5f6c0aeacfcb21e7853ab4879f23ec8ae5e042 x264 supports OpenCL] for some lookahead operations. There are also some proprietary encoders that utilize the GPU, but that does not mean they are well optimized, though encoding time may be faster; and they might be [http://phoronix.com/forums/showthread.php?50697-Test-tool-for-snb-h264-encoder-in-libva-git&p=205580#post205580 worse than vanilla x264], and possibly slower. Regardless, FFmpeg today doesn't support any means of GPU encoding, outside of libx264. 180 193 181 194 === Encoding for dumb players === 182 195 183 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.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.
