Changes between Version 12 and Version 13 of x264EncodingGuide
- Timestamp:
- 08/14/2012 07:31:04 PM (9 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
x264EncodingGuide
v12 v13 3 3 x264 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. 4 4 5 There are two ratecontrol modes that are usually suggested for general use: [#crf Constant Rate Factor (CRF)] and[#twopass Two-Pass encoding]. 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.5 There are two ratecontrol modes that are usually suggested for general use: [#crf Constant Rate Factor (CRF)] or ABR with [#twopass Two-Pass encoding]. 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. 6 6 7 7 If you need help compiling and installing libx264 see one of our [wiki:CompilationGuide FFmpeg and x264 compiling guides]. 8 8 9 9 == Constant Rate Factor (CRF) ==#crf 10 This method will allow you to choose a certain output quality for the whole file and output file size is of less importance. This provides maximum compression effectiveness with a single pass and each video gets the bitrate it needs. The downsides is that you can't tell it to get a specific filesize or not go over a specific size.10 This method allows you to choose 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. 11 11 12 12 === 1. Choose a CRF value === … … 20 20 You can also choose a tune and/or profile. 21 21 22 === 3. Continue encoding===22 === 3. Use your settings === 23 23 Use these same settings for the rest of your videos if you are encoding more. This will ensure that they will all have the same quality. 24 24 … … 79 79 ---- 80 80 81 == = Additional Information ===81 == Additional Information == 82 82 83 ABR (Average Bit Rate). Like 83 84 === ABR (Average Bit Rate) === 85 84 86 {{{ 85 87 ffmpeg -i input -vcodec libx264 -b 1000k ... 86 88 }}} 87 89 88 This 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.90 This is the default, and provides something of a "running average" target, with the end goal that the final file match this number "overall on average" (so basically, if it gets a lot of black frames, which cost very little, it will encode them with less than the requested bitrate, but then 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 swings. 89 91 90 You can "fake" a Constant Bit Rate setting by tuning the parameters of the ABR, like 92 === CBR (Constant Bit Rate) === 93 94 There is no native CBR mode, but you can "simulate" a constant bit rate setting by tuning the parameters of ABR, like 91 95 {{{ 92 ffmpeg -i myfile.avi-vcodec libx264 -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v96 ffmpeg -i input -vcodec libx264 -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v 93 97 }}} 94 98 95 bufsize is the "rate control buffer" so it will keep that "average" (4000k in this case) across every block of 1835k. So basically it is assumed that the receiver/end player will buffer that much data so it's ok to fluctuate within that time span.99 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 quantity. 96 100 97 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 to try to satisfy the requested parameters).101 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). 98 102 99 You can also "fake" a maximum bit rate by specifying both crf *and* maxrate settings, like 103 === CRF with maximum bit rate === 104 105 You can also also use a crf with a maximum bit rate by specifying both crf *and* maxrate settings, like 100 106 {{{ 101 107 ffmpeg -i input -vcodec libx264 -crf 20 -maxrate 400k -bufsize 1835k 102 108 }}} 103 109 104 This will effectively "target" crf 20, but if the output exceeds 400k , it will degrade to something less than crf 20 in that case.110 This will effectively "target" crf 20, but if the output exceeds 400kb/s, it will degrade to something less than crf 20 in that case. 105 111 106 112 ---- … … 115 121 == FAQ == 116 122 === Will two-pass provide a better quality than CRF? === 117 [http://doom10.org/index.php?PHPSESSID=okj08qe73ictdtv532augv8nu7&topic=267.msg2071#msg2071 No] .123 [http://doom10.org/index.php?PHPSESSID=okj08qe73ictdtv532augv8nu7&topic=267.msg2071#msg2071 No], though it does allow you to target a file size accurately. 118 124 119 125 === Why is `placebo` a waste of time? ===


