X264参数介绍
Presets
A system designed to reduce the work needed to generate sane, efficient commandlines that do what you want. For information on what options these settings toggle, check the output of x264.exe --fullhelp.
profile
Default: not set
Limit the profile of the output stream. If you specify a profile, it overrides all other settings, so if you use it, you will be guaranteed a compatible stream. If you set this option, you cannot use lossless encoding (–qp 0 or --crf 0).
You should set this if you know your playback device only supports a certain profile. Most decoders support High profile, so there’s no need to set this.
Values available: baseline, main, high.
preset
Default: medium
Change options to trade off compression efficiency against encoding speed. If you specify a preset, the changes it makes will be applied before all other parameters are applied.
You should generally set this option to the slowest you can bear.
Values available: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo.
tune
Default: Not Set
Tune options to further optimize them for your input content. If you specify a tuning, the changes will be applied after --preset but before all other parameters.
If your source content matches one of the available tunings you can use this, otherwise leave unset.
Values available: film, animation, grain, stillimage, psnr, ssim, fastdecode, zerolatency.
Frame-type options
keyint
Default: 250
Sets the maximum interval between IDR-frames (aka keyframes) in x264’s output. You can specify “infinite” to never insert non-scenecut IDR-frames.
IDR-frames are ‘delimiters’ in the stream - no frame can reference data from the other side of the IDR-frame. As well as this, IDR-frames are also I-frames, so they don’t reference data from any other frame. This means they can be used as seek points in a video.
Note that I-frames are generally significantly larger than P/B-frames (often 10x or more in low motion scenes), so they can play havoc with ratecontrol when combined with aggressively low VBV settings (eg, sub-second buffer sizes). In these cases, investigate --intra-refresh.
The default setting is fine for most videos. When encoding for Blu-ray, broadcast, live streaming or certain other specialist scenarios you may require a significantly smaller GOP length (often ~1x fps).
See also: --min-keyint, --scenecut, --intra-refresh
min-keyint
Default: auto (MIN(–keyint / 10,–fps))
Sets the minimum length between IDR-frames.
See --keyint for an explanation of IDR-frames. Very small keyint ranges can cause “incorrect” IDR-frame placement (for example, a strobing scene). This option limits the minimum length in frames after each IDR-frame before another can be placed.
The maximum allowed value for min-keyint is --keyint/2+1
Recommendation: Default, or 1x your framerate.
See also: --keyint, --scenecut
no-scenecut
Default: Not Set
Completely disables adaptive I-frame decision.
See also: --scenecut
scenecut
Default: 40
Sets the threshold for I/IDR frame placement (read: scene change detection).
x264 calculates a metric for every frame to estimate how different it is from the previous frame. If the value is lower than scenecut, a ‘scenecut’ is detected. An I-frame is placed if it has been less than --min-keyint frames since the last IDR-frame, otherwise an IDR-frame is placed. Higher values of scenecut increase the number of scenecuts detected. For more information on how the scenecut comparison works, see this doom9 thread.
Setting scenecut to 0 is equivalent to setting --no-scenecut.
Recommendation: Default
See also: --keyint, --min-keyint, --no-scenecut
no-cabac
Default: Not set
Disables CABAC (Context Adaptive Binary Arithmetic Coder) stream compression and falls back to the less efficient CAVLC (Context Adaptive Variable Length Coder) system. Significantly reduces both the compression efficiency (10-20% typically) and the decoding requirements.
ref
Default: 3
Controls the size of the DPB (Decoded Picture Buffer). The range is from 0-16. In short, this value is the number of previous frames each P-frame can use as references. (B-frames can use one or two fewer, depending on if they are used as references or not.) The minimum number of refs that can be referenced is 1.
Also note that the H.264 spec limits DPB size for each level. If adhering to Level 4.1 specs, the maximum refs for 720p and 1080p video are 9 and 4 respectively. You can read more about levels and 4.1 in particular under --level.
See also: --b-pyramid, --no-mixed-refs, --level
no-deblock
Default: Not Set
Completely disables the loop filter. Not Recommended.
See Also: --deblock
deblock
Default: 0:0
Controls the loop filter (aka inloop deblocker), which is part of the H.264 standard. It is very efficient in terms of encoding time vs. quality gained.
You can find a good description of how the loop filter parameters work in this doom9 thread (see the initial post and akupenguin’s replies).
See Also: --no-deblock
slices
Default: 0
Sets the number of slices per frame, and forces rectangular slices. (Overridden by either --slice-max-size or --slice-max-mbs if they are set.)
If you are encoding for Blu-ray, set this to four. Otherwise, don’t use this unless you know you need to.
See Also: --slice-max-size, --slice-max-mbs.
slice-max-size
Default: 0
Sets the maximum slice size in bytes, including estimated NAL overhead. (Currently is not compatible with --interlaced.)
See Also: --slices
slice-max-mbs
Default: 0
Sets the maximum slice size in macroblocks. (Currently is not compatible with --interlaced.)
See Also: --slices
Ratecontrol
qp
Default: Not Set
The first of three possible ratecontrol methods. Set x264 to encode the movie in Constant Quantizer mode. The number you give here specifies the P-frame quantizer. The quantizer used for I- and B-frames is derived from --ipratio and --pbratio. CQ mode targets a certain quantizer, which means final filesize is not known (although it can be reasonably accurately estimated with some methods). A setting of 0 will produce lossless output. qp produces larger files than --crf for the same visual quality. qp mode also disables adaptive quantization, since by definition ‘constant quantizer’ implies no adaptive quantization.
This option is mutually exclusive with --bitrate and --crf. See this writeup for more information on the various ratecontrol systems.
You should generally use --crf instead, although qp doesn’t require lookahead to run and thus can be faster.
See also: --bitrate, --crf, --ipratio, --pbratio
bitrate
Default: Not Set
The second of three ratecontrol methods. Encode the video in target bitrate mode. Target bitrate mode means the final filesize is known, but the final quality is not. x264 will attempt to encode the video to target the given bitrate as the overall average. The parameter given is the bitrate in kilobits/sec. (8bits = 1byte and so on). Note that 1 kilobit is 1000, not 1024 bits.
This setting is often used in conjunction with --pass for two-pass encoding.
This option is mutually exclusive with --qp and --crf. See this writeup for more information on the various ratecontrol systems.
See also: --qp, --crf, --ratetol, --pass, --stats
crf
Default: 23.0
The final ratecontrol method: Constant Ratefactor. While qp targets a certain quantizer, and bitrate targets a certain filesize, crf targets a certain ‘quality’. The idea is for crf n to give the same perceptual quality as qp n, just in a smaller space. The arbitrary unit of measure for crf values is the “ratefactor”.
CRF achieves this by reducing the quality of ‘less important’ frames. In this context, ‘less important’ means frames in complex or high-motion scenes, where quality is either more expensive (in terms of bits) or less visible, will have their quantizer increased. The bits saved in frames like these are redistributed to frames where they will be more effective.
CRF will take less time than a 2pass bitrate encode, because the ‘first pass’ from a 2pass encode was skipped. On the other hand, it’s impossible to predict the bitrate a CRF encode will come out to. It’s up to you to decide which rate-control mode is better for your circumstances.
This option is mutually exclusive with qp and bitrate. See this writeup for more information on the various ratecontrol systems.
See also: --qp, --bitrate
crf-max
Default: Not set
A similar setting to --qpmax except instead of specifying a maximum quantizer you’re specifying a maximum ratefactor. This option only works when you are using CRF and have VBV enabled. It prevents x264 from reducing the ratefactor (aka “quality”) below the given value even when doing so would violate VBV constraints. This setting is mostly applicable to custom streaming servers. More information can be found in the initial commit message.
See Also: --crf, --vbv-maxrate, --vbv-bufsize
qpmin
Default: 0
Defines the minimum quantizer that x264 will ever use. The lower the quantizer, the closer the output is to the input. At some point, the output of x264 will look the same as the input, even though it is not exactly the same. Usually there is no reason to allow x264 to spend more bits than this on any particular macroblock.
With adaptive quantization enabled (the default), raising qpmin is discouraged because this could reduce the quality of flat background areas of the frame.
See also: --qpmax, --ipratio
qpmax
Default: 51
The opposite of qpmin, above. Defines the maximum quantizer that x264 can use. The default of 51 is the highest quantizer available for use in the H.264 spec, and is extremely low quality. This default effectively disables qpmax. You may want to set this lower (values in the 30-40 range are generally as low as you’d go) if you want to cap the minimum quality x264 can output, but adjusting it is generally not recommended.
See also: --qpmin, --pbratio, --crf-max
qpstep
Default: 4
Sets the maximum change in quantizer between two frames.
Analysis
partitions
Default: 'p8x8,b8x8,i8x8,i4x4’
H.264 video is split up into 16x16 macroblocks during compression. These blocks can be further split up into smaller partitions, which is what this option controls.
With this option, you enable individual partitions. Partitions are enabled per-frametype (i.e., I, P, B). The available partitions are p8x8, p4x4, b8x8, i8x8, and i4x4.
I: i8x8, i4x4
P: p8x8 (also enables p16x8/p8x16), p4x4 (also enables p8x4/p4x8)
B: b8x8 (also enables b16x8/b8x16)
You can also set ‘none’ or ‘all’.
p4x4 is generally not very useful and has an extremely high ratio of speed cost to resulting quality gain.
See also: --no-8x8dct
me
Default: 'hex’
Set the full-pixel motion estimation method. There are five choices:
dia (diamond) is the simplest search, consisting of starting at the best predictor, checking the motion vectors at one pixel upwards, left, down, and to the right, picking the best, and repeating the process until it no longer finds any better motion vector.
hex (hexagon) consists of a similar strategy, except it uses a range-2 search of 6 surrounding points, thus the name. It is considerably more efficient than dia and hardly any slower, and therefore makes a good choice for general-use encoding.
umh (uneven multi-hex) is considerably slower than hex, but searches a complex multi-hexagon pattern in order to avoid missing harder-to-find motion vectors. Unlike hex and dia, the merange parameter directly controls umh’s search radius, allowing one to increase or decrease the size of the wide search.
esa (exhaustive) is a highly optimized intelligent search of the entire motion search space within merange of the best predictor. It is mathematically equivalent to the bruteforce method of searching every single motion vector in that area, though faster. However, it is still considerably slower than UMH, with not too much benefit, so is not particularly useful for everyday encoding.
tesa (transformed exhaustive) is an algorithm which attempts to approximate the effect of running a Hadamard transform comparison at each motion vector; like exhaustive, but a little bit better and a little bit slower.
See also: --merange
Input/Output
output
Default: Not Set.
Specifies output filename. The extension you specify determines the output format of your video. If the extension is not recognised the default output format is the raw video stream (generally stored with the .264 extension).
The special location NUL (Windows) or /dev/null (Unix) specifies the output should be discarded. This is particularly useful when using pass 1, as the only output you care about is that from stats.
sar
Default: Not Set
Specifies the input video’s Sample Aspect Ratio (SAR) to be used by the encoder in width:height. This in conjunction with frame dimensions can be used to encode an anamorphic output by determining the Display Aspect Ratio (DAR) via the formula: DAR = SAR x width/height
See Main Article here Recommendation: You might need to set this if you’re using the resize filter and encoding with anamorphic input.
fps
Default: autodetected
Specifies video framerate as either a float (29.970) a rational (30000/1001), or an integer (2997/100) value. x264 detects and uses the framerate from the input stream header when available (y4m, avs, ffms and lavf demuxer), otherwise uses 25. Setting this implies force-cfr.
If you are using raw YUV input and --bitrate-based ratecontrol, you need to specify the correct framerate using this parameter or --tcfile-in. x264 won’t hit your target bitrate otherwise.
frames
Default: Not Set
Specifies the maximum number of frames to encode, allowing the encode to finish at any point before the end of the source.
Recommendation: Default
level
Default: -1 (auto)
Sets the level flag in the output bitstream (as defined by Annex A of the H.264 standard). Permissible levels are:
1 1.1 1.2 1.3 2 2.1 2.2 3 3.1 3.2 4 4.1 4.2 5 5.1
(Level 1b is not a supported value.)
If you do not specify --level on the commandline, x264 will attempt to autodetect the level. This detection is not perfect and may underestimate the level if you are not using VBV. x264 will also automatically limit the DPB size (see --ref) to remain in compliance with the level you select (unless you also manually specify --ref).
What Level Do I Pick?
Level 4.1 is often considered the highest level you can rely on desktop consumer hardware to support. Blu-ray Discs only support level 4.1, and many non-mobile devices like the Xbox 360 specify level 4.1 as the highest they officially support. Mobile devices like the iPhone/Android are a totally different story.
Wikipedia has a nice chart detailing the restrictions for each level, if you want to read it.
Recommendation: Default, unless you are aiming for a specific device.
引自:https://www.chaneru.com/Roku/HLS/X264_Settings.htm
可参考网站:http://www.360doc.com/content/13/1016/13/13084517_321845566.shtml