| 10 | | The goal of this H.264 video encoding guide is to inform new users how to create a high-quality video using the encoder x264. |
| 11 | | |
| 12 | | There are two rate control modes that are usually suggested for general use: [#crf Constant Rate Factor (CRF)] or [#twopass Two-Pass ABR]. Rate control decides how many bits will be used for each frame. This will determine the file size and also how quality is distributed. To know more about what the different rate control modes do see [http://slhck.info/video/2017/03/01/rate-control.html this post]. |
| 13 | | |
| 14 | | If you need help compiling and installing libx264 see one of our [[CompilationGuide|compiling guides]]. |
| 15 | | |
| 16 | | ---- |
| | 10 | This guide focuses on the encoder x264. It assumes you have `ffmpeg` compiled with `--enable-libx264`. If you need help compiling and installing see one of our [[CompilationGuide|compiling guides]]. See [[HWAccelIntro]] for information on supported hardware H.264 encoders. |
| | 11 | |
| | 12 | ---- |
| | 13 | |
| | 14 | There are two rate control modes that are usually suggested for general use: [#crf Constant Rate Factor (CRF)] or [#twopass Two-Pass ABR]. Rate control decides how many bits will be used for each frame. This will determine the file size and also how quality is distributed. To know more about what the different rate control modes do see [https://slhck.info/video/2017/03/01/rate-control.html this post]. |
| 75 | | Another optional setting is `-profile:v` which will limit the output to a specific H.264 profile. Omit this unless your 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. |
| | 73 | The `-profile:v` option limits the output to a specific H.264 profile. Some devices (mostly very old or obsolete) only support the more limited ''Constrained Baseline'' or ''Main'' profiles. You can set these profiles with `-profile:v baseline` or `-profile:v main`. |
| | 74 | |
| | 75 | Most modern devices support the more advanced ''High'' profile. Unless you need to support limited devices the recommendation is to omit setting the profile which will allow x264 to automatically select the appropriate profile. |
| | 76 | |
| | 77 | Note that usage of `-profile:v` is incompatible with lossless encoding. |
| 219 | | == Compatibility == |
| 220 | | |
| 221 | | === All devices === |
| 222 | | |
| 223 | | If you want your videos to have highest compatibility with ancient devices (e.g., old Android phones): |
| 224 | | |
| 225 | | {{{ |
| 226 | | -profile:v baseline -level 3.0 |
| 227 | | }}} |
| 228 | | |
| 229 | | This 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 compared to what is needed to achieve the same quality in higher profiles. |
| 230 | | |
| 231 | | === iOS === |
| 232 | | |
| 233 | | ||||||||= '''iOS Compatability''' ([https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/UsingHTTPLiveStreaming/UsingHTTPLiveStreaming.html#//apple_ref/doc/uid/TP40008332-CH102-SW8 source]) =|| |
| 234 | | ||= '''Profile''' =||= '''Level''' =||= '''Devices''' =||= '''Options''' =|| |
| 235 | | || Baseline || 3.0 || All devices || `-profile:v baseline -level 3.0` || |
| 236 | | || Baseline || 3.1 || iPhone 3G and later, iPod touch 2nd generation and later || `-profile:v baseline -level 3.1` || |
| 237 | | || Main || 3.1 || iPad (all versions), Apple TV 2 and later, iPhone 4 and later || `-profile:v main -level 3.1` || |
| 238 | | || Main || 4.0 || Apple TV 3 and later, iPad 2 and later, iPhone 4s and later || `-profile:v main -level 4.0` || |
| 239 | | || High || 4.0 || Apple TV 3 and later, iPad 2 and later, iPhone 4s and later || `-profile:v high -level 4.0` || |
| 240 | | || High || 4.1 || iPad 2 and later, iPhone 4s and later, iPhone 5c and later || `-profile:v high -level 4.1` || |
| 241 | | || High || 4.2 || iPad Air and later, iPhone 5s and later || `-profile:v high -level 4.2` || |
| 242 | | |
| 243 | | === !QuickTime === |
| 244 | | |
| 245 | | Although other pixel formats may be supported, YUV planar color space with 4:2:0 chroma subsampling is a safe pixel format for H.264 video; use `-vf format=yuv420p` or `-pix_fmt yuv420p`. |
| 246 | | |
| 247 | | === Blu-ray === |
| | 221 | == Blu-ray == |