X264 Settings
From MeWiki
This page intends to give explanations for all options in x264, as well as those for common patches. The page is ordered by appearance in x264 --fullhelp.
See also x264 Stats Output and x264 Encoding Suggestions.
x264 Settings
Presets
A system added in r1177 designed to reduce the work needed to generate sane, efficient commandlines that do what you want. For full information on what options these settings toggle, check the output of x264.exe --fullhelp.
profile
Default: high
Limit the profile of the output stream. This option 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).
The available options are:
- baseline
- main
- high
Recommendation: High, unless your playback device only supports main or baseline.
preset
Default: Medium
Change options to trade off compression efficiency and quality. If you specify a preset, the changes it makes will be applied before all other parameters are applied.
- ultrafast
- veryfast
- faster
- fast
- medium
- slow
- slower
- veryslow
- placebo
Recommendation: The slowest you can bear.
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.
- film
- animation
- grain
- psnr
- ssim
- fastdecode
- zerolatency
- touhou
Recommendation: According to your content. Do not specify if your source doesn't match any of the options.
slow-firstpass
Default: Not Set
With the advent of the Preset system in r1177, using --pass 1 applies the following settings at the end of parsing the command line:
- ref 1
- no-8x8dct
- partitions i4x4 (if originally enabled, else none)
- me dia
- subme MIN( 2, subme )
- trellis 0
This feature is automatically disabled with preset placebo. To otherwise disable the feature, set this option.
See pass.
Frame-type options
keyint
Default: 250
Sets the maximum interval between IDR-frames (aka keyframes) in x264's output.
Normally, x264 will only make a frame an IDR-frame if it passes the threshold set by scenecut. This setting lets you place an upper bound on length of time before an IDR-frame appears. IDR-frames are 'delimiters' in the stream - no frame can reference data from the other side of the IDR-frame. These mean they can be used as points to randomly seek to in the movie. Note that while an IDR-frame is necessarily an I-frame, not all I-frames are IDR-frames. Most of the time x264 will make the first frame of a new scene an IDR-frame (see scenecut), so much of the time this setting will not come into play. Higher settings can improve compression (reducing the number of forced IDR-frames which would otherwise be smaller P or B frames). Lower settings reduce the time (computation) needed to seek to a random frame.
Recommendation: If targeting Blu-ray, set this to 1x your framerate, otherwise set this to 5-10x your framerate.
See also: min-keyint, scenecut, intra-refresh
min-keyint
Default: 25
Sets the minimum length between IDR frames.
See keyint for an explanation of IDR frames. Very small IDR ranges can reduce 'incorrect' frame placement (for example, a strobing scene). This option limits the minimum length after each IDR frame before another can be placed.
Recommendation: Default, or 1x your framerate.
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
intra-refresh
Default: Off
Disables IDR-frames, instead x264 uses intra coding for each macroblock in the frame every keyint frames. Blocks are refreshed in a horizontally scrolling column - the 'refresh wave'. This benefits low-latency streaming by making it possible to achieve more constant frame sizes than is possible with standard IDR-frames. It also increases the resilience of the video stream to packet loss. This option does reduce compression efficiency, hence only use it when needed.
Fun facts:
- When using intra-refresh, keyint is limited to the width of the video in macroblocks (ie, divide the horizontal resolution by 16 and round up). For example, a 1080p film would restrict keyint to 120, while a DVD could only have a keyint of 45.
- The first frame is still an IDR frame.
- Intra-blocks are placed only in P-frames - the refresh wave is wider in the first P-frame after one or more B-frames.
- The loss in compression efficiency comes primarily from the fact macroblocks on the 'new' (left) side of the refresh wave can't refer to data on the 'old' (right) side, and that keyint is limited by video resolution.
Recommendation: Default
bframes
Default: 3
Sets the maximum number of concurrent B-frames that x264 can use.
Without B-frames, a typical x264 stream has frametypes like so: IPPPPP...PI. With --bframes 2, up to two consecutive P-frames can be replaced with B-frames, like: IBPBBPBPPPB...PI.
B-frames are similar to P-frames, except they can use motion prediction from future frames as well. This can lead to significantly better efficiency in terms of compression ratio. Their average quality is controlled by pbratio. Use b-adapt to force x264 to use the prescribed number of B-frames whenever possible.
Bonus info:
- x264 also occasionally distinguishes between two different sorts of B-frames. A 'B' can refer to a B-frame that is used as a reference by other frames, while 'b' can refer to a B-frame that is not. If you see a mix of 'B' and 'b', it's usually related to the above. When the difference is not important, just 'B' is generally used to refer to all B-frames.
- For more information about the choices x264 makes between P or B frames for each candidate frame, see this ffmpeg-devel mail. In this case, frame types will look like this (in display order) (assuming --bframes 3): IBBBPBBBPBPI.
- For an idea of how many B-frames are used in your encode, read the 'consecutive B-frames' line in x264's stats output after an encode, which shows the number of B-frame sequences exactly 'n' frames long, for n=0 (ie: PP) to the maximum allowed.
Recommendation: Unless you use --b-adapt 2, choose --bframes 16, the maximum. This is the fastest and most flexible option for the encoder. If you use --b-adapt 2, higher values will significantly slow the encoding process without major benefit. Try values more like 2-5.
Sometimes you'll have to settle for less: Blu-Ray limits the maximum number of B-frames to 3.
See also: no-b-adapt, b-bias, b-pyramid, ref, pbratio, partitions, weightb, b-rdo, bime
b-adapt
Default: 1
Set the adaptive B-frame placement decision algorithm. This setting controls how x264 decides between placing a P- or B-frame.
- 0. Disabled. Pick B-frames always. This is the same as what the older --no-b-adapt setting did.
- 1. Old algorithm, faster, speed slightly increases with higher b-frames setting.
- 2. New algorithm, slower, speed significantly decreases with higher b-frames setting.
Recommendation: Default, use 2 if you have time to waste.
Note: For a multi-pass encode, this option is only needed for the first pass where frame types are decided.
b-bias
Default: 0
Controls the likelihood of B-frames being used instead of P-frames. Values great than 0 increase the weighting towards B-frames, while values less than 0 do the opposite. This number is not a percentage or absolute increase, just an arbitrary metric. The range is from -100 to 100. Note that a value of 100 does not guarantee every P-frame will be converted (use --b-adapt 0 for that).
Only use this if you think you make better ratecontrol decisions than x264.
Recommendation: 0
b-pyramid
Default: none
Allow the use of B-frames as references for other frames. Without this setting, frames can only reference I- or P-frames. Although I/P-frames are more valued as references because of their higher quality, B-frames can also be useful. B-frames designated as references will get a quantizer halfway between P-frames and normal B-frames. You need to use at least two B-frames before B-pyramid will work.
- none: do not allow B-frames to be used as references.
- strict: allow one B-frame per minigop to be used as reference; enforces restrictions imposed by the Blu-ray standard.
- normal: allow numerous B-frames per minigop to be used as references.
Recommendation: Set to 'normal'. If you're encoding for Blu-Ray, use 'none' or 'strict'. See also: b-frames, refs, no-mixed-refs
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.
Recommendation: Use CABAC (i.e. don't set this option) unless your decoder really really sucks.
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.
Note, this setting is used to control the number of refs used. See this doom9 post outlining the difference.
Also note that the ITU-T specification limits DPB and thus limits the ref for each level. If adhering to Level 4.1 specs, the maximum refs for full height 720p and 1080p video are 9 and 4, respectively. But if the video's height is not the full 720 or 1080 pixels, a higher ref can be used. Level 4.1 is the level implemented on Blu-ray and HD DVD, and the highest level supported in most consumer electronics which support H.264 playback, including Xbox 360, Playstation 3, and Popcorn Hour A-100 Media Extender.
The general formula for calculating maximum ref is as follows; the value should be rounded down:
maximum ref = MaxDPB * 1024 / ( width * height * 1.5)
Recommendation: Around 4-6. Each increase has a reduced benefit and constant speed loss. Very large numbers of refs are normally not very useful, but even up to 16 can be helpful for animated content, video game capture, CGI, and other similar content.
See also: b-pyramid, no-mixed-refs, level
no-deblock
Default: Not Set
Completely disables the loop filter.
Recommendation: You don't really ever want to disable the inloop deblocker.
See Also: deblock
deblock
Default: 0:0
Controls the loop filter (aka inloop deblocker), which is part of the H.264 standard. The loop filter takes a rather large slice of decoding time for a single item, and is responsible for a similar slice of the overall quality output. 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).
Recommendation: Default. Lower values can be used if you feel x264 is blurring too much, although this only helps if you have enough spare bitrate. Sane values are probably within the range -3 to 3. Note that at higher bitrates (and thus lower quantizers), deblocking is inherently weaker, so you do not need to 'compensate' for higher bitrate with lower deblocking settings or vice versa.
See Also: no-deblock
interlaced
Default: Not Set
Enable interlaced encoding. x264's interlaced encoding is inherently less efficient than its progressive encoding, so it is probably better to deinterlace an interlaced source before encoding rather than use interlaced mode.
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.)
Recommendation: Don't use slices unless you are encoding for Blu-ray (since they hurt coding effiency), then use 4.
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
constrained-intra
Default: Not Set
Enable constrained intra prediction, which is required for the base layer of SVC encodes.
Recommendation: Not set, since it significantly reduces compression.
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.
Recommendation: Use crf instead
See also: bitrate, crf, ipratio, pbratio
bitrate
Default: Not Set
The second of three ratecontrol methods. Encode the video in target bitrate mode. x264 will attempt to encode the video to target the given bitrate as the final average. The parameter given is the bitrate in kilobits/sec. (8bits = 1byte and so on). This setting is usually used in conjunction with pass for two-pass encoding. Target bitrate mode means the final filesize is known, but the final quality is not (although it's possible to estimate with a reasonable degree of accuracy). It is generally not recommended to use bitrate mode without 2pass encoding.
This options is mutually exclusive with qp and crf. See this writeup for more information on the various ratecontrol systems.
Recommendation: Something which results in P-frame quantizers around 18-26. Estimated ranges: for SD resolution: 800kbits-2100kbits. For 720p, 3-6mbit. For 1080p, 8-15mbit+.
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. It is not extremely exact, but reasonably close (and will average out to be accurate over a large number of videos).
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.
When comparing a CRF encode to a 2pass encode at the same bitrate, the CRF encode will be marginally lower quality. On the other hand, it will have taken significantly less time, because the 'first pass' from a 2pass encode was skipped. On the other other hand, it's impossible to predict the bitrate a CRF encode will come out to (without actually performing the encode or a portion of it). 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. Note that at various times in x264's past, the metric mapping crf n to qp n has changed, so crf values are not identical forever as qp values or bitrate values are.
Recommendation: The range 18-26 is probably where you will want to look at. If you need absolutely perfect quality you could go down to 16, but it's probably not worth it. Around 19-21.5 is where a rip will look very good. Higher resolution encoding can generally get away with higher crf values.
rc-lookahead
Default: 40
Sets the number of frames to use for mb-tree ratecontrol and vbv-lookahead. The maximum allowed value is 250.
For the mb-tree portion of this, increasing the frame count generates better results but is also slower. The maximum buffer value used by mb-tree is the MIN( rc-lookahead, keyint )
For the vbv-lookahead portion of this, increasing the frame count generates better stability and accuracy when using vbv. The maximum value used by vbv-lookahead is:
MIN(rc-lookahead, MAX(keyint, MAX(vbv-maxrate, bitrate) / vbv-bufsize * fps))
Recommendation: Default
See Also: no-mbtree, vbv-bufsize, vbv-maxrate
vbv-maxrate
Default: 0
Sets the maximum bitrate in VBV mode.
Recommendation: You should only use VBV if you have a hardware decoder that requires it.
See also: vbv-bufsize, vbv-init
vbv-bufsize
Default: 0
Sets the maximum size of the VBV buffer
Recommendation: You should only use VBV if you have a hardware decoder that requires it. The buffer chosen is generally specific to the target device.
See also: vbv-maxsize, vbv-init
vbv-init
Default: 0.9
Sets the initial fill of the VBV buffer.
If it is less than 1, then the the initial fill is: vbv-init * vbv-bufsize. Otherwise if it is greater than 1, it is interpreted as the initial fill in kbits.
Recommendation: Default. This shouldn't be adjusted.
See also: vbv-maxsize, vbv-bufsize
qpmin
Default: 10
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 frame / area. For most videos, anything below q16 will be perceptually lossless in this way, and anything below the conservative default of q10 will certainly be.
You can use this setting to prevent creating needlessly oversized files. Take note if you set this aggressively (e.g., to 16 or such), and your bitrate-based encode is not coming out as large as it should be, this is possibly the reason why. You should analyse x264's stats output at the end of encoding and see if all frames are at the minimum quantizer.
With adaptive quantization enabled (on by default), raising qpmin beyond its default is strongly discouraged because this could reduce the quality of flat background areas of the frame.
Recommendation: Default
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.
Recommendation: Default
qpstep
Default: 4
Sets the maximum change in quantizer between two frames. If a frame is encoded at q20, the next frame's quantizer will be capped if it is lower than 16 or greater than 24.
The purpose behind this setting is to reduce the possibility of any large quality jumps in the output video. The reasoning is that it's better to slow this change over a few frames than do it in one. Remember that most videos at standard quality will range at most between quantizers 16-30, this setting can only distort the bitrate allocation for three frames max. The default value is a good one.
Recommendation: Default
ratetol
Default: 1.0
This is a double purpose parameter:
- In 1-pass bitrate encodes, this settings controls the percentage that x264 can miss the target average bitrate by. You can set this to 'inf' to disable this overflow detection completely. The lowest you can set this is to 0.01. The higher you set this to the better x264 can react to complex scenes near the end of the movie. The unit of measure for this purpose is percent (eg, 1.0 = 1% bitrate deviation allowed).
- Many movies (any action movie, for instance) are most complex at the climatic finale. As a 1pass encode doesn't know this, the number of bits required for the end is usually underestimated. A ratetol of inf can mitigate this by allowing the encode to function more like a crf encode, but the filesize will blow out.
- When VBV is activated (ie, you're specified --vbv-* options), this setting also affects VBV aggressiveness. Setting this higher allows VBV to fluctuate more at the risk of possibly violating the VBV settings. For this purpose, the unit of measure is arbitrary.
ipratio
Default: 1.40
Sets the target average increase in bitrate for I-frames as compared to P-frames. Seen as 'keyframe boost' in Xvid. Higher values increase the quality of I-frames. This makes them better references, which can improve the overall image quality. The problem is that the extra bits taken by the I-frames are taken from the P- and B-frames, which makes this variable a balancing act.
See also: pbratio
pbratio
Default: 1.30
Sets the targest average reduction in bitrate for B-frames as compared to P-frames. This variable works more or less the same as ipratio, above. Not used with mbtree, which calculates the optimum value automatically.
See also: ipratio
chroma-qp-offset
Default: 0
Normally, x264 encodes all three colour planes (luma, U (chroma), V (chroma)) at the same quantizer. This value will be added to the quantizers for the U and V planes. This allows you to bias x264 in favour of brightness (luma) by setting positive values (chroma fields will have higher quantizers), or in favour of colour (chroma). Remember than x264 encodes video as YV12, which means chroma takes up only half the space luma does anyway.
x264 automatically lowers this when using psy-rd and/or psy-trellis to compensate for it increasing the quality of luma, and subsequently decreasing the quality of chroma.
Note: x264 only encodes the luma and chroma planes at the same quantizer up to quantizer 29. After this, chroma is progressively quantized by a lower amount than luma until you end with luma at q51 and chroma at q39. This behavior is not adjustable, as it is required by the H.264 standard.
aq-mode
Adaptive Quantization Mode
Default: 1
Without AQ, x264 tends to underallocate bits to less-detailed sections. AQ is used to better distribute the available bits between all macroblocks in the video. This setting changes what scope AQ re-arranges bits in:
- 0: Do not use AQ at all.
- 1: Allow AQ to redistribute bits across the whole video and within frames.
- 2: Auto-variance AQ (experimental) uses log(var)^2 instead of log(var) and attempts to adapt strength per-frame.
Recommendation: Default
See also: aq-strength
aq-strength
Adaptive Quantization Strength
Default: 1.0
Sets the strength of AQ bias towards low detail ('flat') macroblocks. Negative values are not allowed. Values more than a couple of hundred percent off from 1.0 are probably a bad idea.
Recommendation: Default
See also: aq-mode
pass
Default: Not Set
This is an important setting for 2pass encoding. It controls what x264 will do with the stats file. It has three settings:
- 1: Create a new stats file. Use this on the first pass.
- 2: Read the stats file. Use this on the final pass.
- 3: Read the stats file, and update it as well.
The stats file contains information about every input frame, which can be input to x264 in order to improve the output. The idea is you run a first pass to generate the stats file, and the second pass will create an optimized encode of the video. The improvement is mostly gained from better ratecontrol.
See also: stats, bitrate, slow-firstpass.
stats
Default: 'x264_2pass.log'
Set the location that x264 will read/write the pass statsfile to/from.
See also: pass
no-mbtree
Default: Not Set
Disable macroblock tree ratecontrol. Using macroblock tree ratecontrol overall improves the compression by keeping track of temporal propagation across frames and weighting accordingly. Requires a new large statsfile in addition to the already existing for multipass encodes.
Recommendation: Default
See Also: rc-lookahead
qcomp
Default: 0.60
Quantizer curve compression factor. 0.0 => Constant Bitrate, 1.0 => Constant Quantizer.
When used with mbtree, it affects the strength of mbtree. (Higher qcomp = weaker mbtree).
Recommendation: Default
See Also: rceq, cplxblur, qblur
cplxblur
Default: 20
Apply a gaussian blur with the given radius to the quantizer curve. This means that the quantizer assigned to each frame is blurred temporally with its neighbours to limit quantizer fluctuations.
qblur
Default: 0.5
Apply a gaussian blur with the given radius to the quantizer curve, after curve compression. Not a very important setting.
See also: rceq, qcomp, cplxblur
zones
Default: Not Set
Tweak settings for specific sections of the video. You can modify most x264 options per-zone.
- A single zone takes the form of <start frame>,<end frame>,<options>
- Multiple zones are separated from each other with a '/'
Options:
These two options are special. You can only set one per zone, and if you set one, it must be the first option listed for the zone:
- b=<float> applies a bitrate multiplier on the zone. Useful for extra tweaking of high- and low-action scenes.
- q=<int> applies a constant quantizer on the zone. Useful for applying to a range of frames.
The other available options are as follows:
- ref=<integer>
- b-bias=<integer>
- scenecut=<integer>
- no-deblock
- deblock=<integer>:<integer>
- deadzone-intra=<integer>
- deadzone-inter=<integer>
- direct=<string>
- merange=<integer>
- nr=<integer>
- subme=<integer>
- trellis=<integer>
- (no-)chroma-me
- (no-)dct-decimate
- (no-)fast-pskip
- (no-)mixed-refs
- psy-rd=<float>:<float>
- me=<string>
- no-8x8dct
- b-pyramid=<string>
Limitations:
- The number of reference frames for a zone can never exceed what was specified with --ref
- Scenecut can not be turned on and off; only varied if originally active (>0)
- Merange can not exceed what was originally specified if --me esa/tesa
- Subme can't be changed if the original commandline specified it as 0.
- You can't set me to esa or tesa if --me was originally specified as dia, hex, or umh
Example: 0,1000,b=2/1001,2000,q=20,me=3,b-bias=-1000
Recommendation: Default
qpfile
Manual override to standard ratecontrol. Specify a file that gives the quantizer and frametype for specified frames. The format is 'framenum frametype quantizer'. For example:
0 I 18 < IDR (key) I-frame 1 P 20 < P-frame 2 B 22 < Referenced B-frame 3 i 21 < Non-IDR (non-key) I-frame 4 b 18 < Non-referenced B-frame
- You don't need to specify every frame
- Using -1 as the desired quantizer allows x264 to choose the optimal quantizer value, useful when only needing to set the frametype
- Having a large number of specified frame types and quantizers while still letting x264 choose intermittently decreases x264's performance
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: 8x8dct
direct
Default: 'spatial'
Set prediction mode for 'direct' motion vectors. There are two modes available: spatial and temporal. You can also select none to disable direct MVs, and auto to allow x264 to swap between them as it sees fit. If you set auto, x264 outputs information on the usage at the end of the encode. 'auto' works best in a 2pass encode, but will work in single-pass encodes too. In first-pass auto mode, x264 keeps a running average of how well each method has so far performed, and picks the next prediction mode from that. Note that you should only enable auto on the second pass if it was enabled on the first pass; if it wasn't, the second pass will default to temporal. Direct none wastes bits and is strongly discouraged.
Recommendation: 'auto'
no-weightb
Default: Not Set
H.264 allows you to 'weight' references in B-frames, which allows you to change how much each reference affects the predicted picture. This disables that feature.
Recommendation: Default
weightp
Default: 2
Enables use of explicit weighted prediction to improve compression in P-frames. Higher modes are slower.
Modes:
- 0: Disabled
- 1: Blind offset (a constant offset of -1)
- 2: Smart analysis with duplicates, designed specifically to improve compression in fades.
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
merange
Default: 16
merange controls the max range of the motion search in pixels. For hex and dia, the range is clamped to 4-16, with a default of 16. For umh and esa, it can be increased beyond the default 16 to allow for a wider-range motion search, which is useful on HD footage and for high-motion footage. Note that for umh, esa, and tesa, increasing merange will significantly slow down encoding.
See also: me
mvrange
Default: 511.75
Set the maximum range of any one motion vector. The default value is the maximum specified by the H.264 standard. It is not level- or profile-dependent, so don't touch it.
Recommendation: Default
mvrange-thread
Default: -1 (auto)
Set the minimum motion vector buffer between threads. Don't touch it.
Recommendation: Default
subme
Default: 7
Set the subpixel estimation complexity. Higher numbers are better. Levels 1-5 simply control the subpixel refinement strength. Level 6 enables RDO for mode decision, and level 8 enables RDO for motion vectors and intra prediction modes. RDO levels are significantly slower than the previous levels.
Using a value less than 2 will enable a faster, and lower quality lookahead mode, as well as cause poorer scenecut decisions to be made, and thus it is not recommended.
Possible Values:
- 0. fullpel only
- 1. QPel SAD 1 iteration
- 2. QPel SATD 2 iterations
- 3. HPel on MB then QPel
- 4. Always QPel
- 5. Multi QPel + bime
- 6. RD on I/P frames
- 7. RD on all frames
- 8. RD refinement on I/P frames
- 9. RD refinement on all frames
- 10. QP-RD (requires trellis=2, aq-mode > 0)
Recommendation: Default, or higher, unless speed is very important.
subq
Alias of subme
psy-rd
Default: 1.0:0.0
The first number is the strength of Psy-RDO to use (requires subme>=6 to activate). The second number is the strength of Psy-Trellis (requires trellis>=1 to activate). Note that Trellis is still considered 'experimental', and almost certainly is a Bad Thing for at least cartoons.
See this thread on doom9 for an explanation of psy-rd.
no-psy
Default: Not Set
Disables all visual optimizations that worsen both PSNR and SSIM. This also disables some internal psy optimizations that aren't settable via x264's command line arguments.
Recommendation: Default
no-mixed-refs
Default: Not Set
Mixed refs will select refs on a per-8x8 partition, rather than per-macroblock basis. This improves quality when using multiple reference frames, albeit at some speed cost. Setting this option will disable it.
Recommendation: Default
See also: ref
no-chroma-me
Default: Not Set
Normally, motion estimation works off both the luma and chroma planes. This disables chroma motion estimation for a small speed boost.
Recommendation: Default
no-8x8dct
Default: Not Set
Adaptive 8x8 DCT enables the intelligent adaptive use of 8x8 transforms in I-frames. This disables the feature.
Recommendation: Default
trellis
Default: 1
Performs Trellis quantization to increase efficiency.
- 0. Disabled
- 1. Enabled only on the final encode of a macroblock
- 2. Enabled on all mode decisions
On Macroblock provides a good compromise between speed and efficiency. On all decisions reduces speed further.
See: Trellis Quantization
Recommendation: Default
Note: Requires CABAC
no-fast-pskip
Default: Not Set
Disables early skip detection on P-frames. Very slightly increases quality at a large speed cost.
Recommendation: Default
no-dct-decimate
Default: Not Set
DCT Decimation will drop DCT blocks it deems "unnecessary". This will improve coding efficiency, with a usually negligible loss in quality. Setting this option will disable it.
Recommendation: Default
nr
Default: Not Set
Performs fast noise reduction. Estimates film noise based on this value and attempts to remove it by dropping small details before quantization. This may not match the quality of a good external noise reduction filter, but it performs very fast.
Recommendation: Default or (100 to 1000 for denoising)
deadzone-inter/intra
Default: Not Set
Set the size of the inter/intra luma quantization deadzone. Deadzones should be in the range of 0 to 32. The deadzone value sets the level of fine detail that x264 will arbitrarily drop without attempting to preserve. Very fine detail is both hard to see and expensive to encode, dropping this detail without attempting to preserve it stops wasting bits on such a low-return section of the video. Deadzone is incompatible with Trellis.
Recommendation: Default
cqm
Default: Flat (Not Set)
Sets custom quantization matrices. The built-in presets are flat or JVT.
Recommendation: Default
See also: cqmfile
cqmfile
Default: Not Set
Sets custom quantization matrices from a specified JM-compatible file. Overrides any other --cqm* options.
Recommendation: Default
See also: cqm
cqm4* / cqm8*
Default: Not Set
- --cqm4: Set all 4x4 quant matrices. Takes a comma-separated list of 16 integers.
- --cqm8: Set all 8x8 quant matrices. Takes a comma-separated list of 64 integers.
- --cqm4i, --cqm4p, --cqm8i, --cqm8p: Set both luma and chroma quant matrices
- --cqm4iy, --cqm4ic, --cqm4py, --cqm4pc: Set individual quant matrices. Same switches exist for cqm8.
Recommendation: Default
Video Usability Info
overscan
Default: undef
How to handle overcan. Overscan is used here in the sense of a device only displaying part of an image.
Possible Values:
- undef - Undefined.
- show - Indicate to show the entire image. (Must be respected)
- crop - Indicate that the image is suitable for playback on devices with overscan. (Not necessarily respected)
Recommendation: Crop before encoding and use show, or default.
videoformat
Default: undef
Indicates what the video was before encoding/digitizing.
Possible Values:
- component
- pal
- ntsc
- secam
- mac
- undef
Recommendation: Whatever your source video was, or undefined.
fullrange
Default: off
Indicates whether to use the full range of luma and chroma levels. If set to off, the limited ranges will be used.
See this page for a simple description.
Recommendation: If your source is digitized from analog video, then set this to off. Otherwise, set it to on.
colorprims
Default: undef
Set what color primaries for converting to RGB.
Possible Values:
- undef
- bt709
- bt470m
- bt470bg
- smpte170m
- smpte240m
- film
Recommendation: Default, unless you know what your source uses.
transfer
Default: undef
Set the opto-electronic transfer characteristics to use. (Sets the gamma curve to use for correction.)
Possible Values
- undef
- bt709
- bt470m
- bt470bg
- linear
- log100
- log316
- smpte170m
- smpte240m
See: Gamma Correction
Recommendation: Default, unless you know what your source uses.
colormatrix
Default: undef
Set the matrix coefficients used in deriving the luma and chroma from the RGB primaries.
Possible Values
- undef
- bt709
- fcc
- bt470bg
- smpte170m
- smpte240m
- GBR
- YCgCo
See: YCbCr
Recommendation: Whatever your sources uses, or default.
chromaloc
Default: 0
Sets the chroma sample location. (as defined in Annex E of the ITU-T Specification).
Values range from 0 to 5.
See x264's vui.txt
Recommendation:
- If you transcode from MPEG1 with proper subsampled 4:2:0, and don't do any color space conversion, you should set this option to 1.
- If you transcode from MPEG2 with proper subsampled 4:2:0, and don't do any color space conversion, you should set this option to 0.
- If you transcode from MPEG4 with proper subsampled 4:2:0, and don't do any color space conversion, you should set this option to 0.
- Otherwise, default.
Input/Output
output
Default: Not Set
Specifies output file name.
Recommendation: Use a custom output file name such as 'Compressed Video.mp4'.
muxer
Default: auto
Specifies what format to write to.
Possible Values
- auto
- raw
- mkv
- flv
- mp4
The 'auto' option will pick a muxer based on the supplied output filename.
See also: output
Recommendation: Default
demuxer
Default: yuv
Sets what demuxer x264 uses for input.
Possible Values
- auto
- yuv
- y4m
- avs
- lavf
- ffms
The 'lavf' and 'ffms2' options require x264 to be compiled with the respective libraries. If either is used, x264 will carry over the timecodes from the input file, provided you don't output to raw. This effectively makes x264 VFR-aware, though not in terms of ratecontrol.
The 'auto' option will pick a demuxer based on the supplied input filename.
Recommendation: Default, or whatever you are passing to x264.
index
Default: Not Set
Sets the index file for the input that x264 will save or load, depending on whether the file already exists or not, and is newer than the input file. If not set, it will always index the input.
NOTE: Currently only works with ffms2, and thus requires x264 to be built with it.
See also: demuxers, FFMS2 API Documentation
Recommendation: Default, unless you want to save a minute amount of time indexing.
sar
Default: Not Set
Specifies the Sample Aspect Ratio (same as Pixel Aspect Ratio) in width:height (of a sample). This is useful for encoding anamorphic video.
See: SAR
Recommendation: See this page.
fps
Default: 25
Specifies video framerate as either a float or a rational. Detects and uses the framerate from the input stream header when available, otherwise uses the default.
Recommendation: Default, unless using raw yuv as input.
seek
Default: Not Set
Specifies the first frame to encode, allowing the encode to begin at any point in the source.
Recommendation: Default
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 include 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. If you do not put --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 controls to limit the max bitrate. Also, x264 does not support recognition of or setting the level as 1b from the specification.
Level 4.1 (the maximum level supported by Blu-Ray) is usually the maximum level supported by consumer devices (Xbox 360, Playstation 3, Popcorn Hour A-100 Media Extender, DXVA decoders, etc). A 5th-generation video iPod is limited to Level 1.3; Classics and later models support up to Level 3.0.
Recommendation: Default, unless you are aiming for a specific device.
verbose
Default: Not Set
Displays statistics for each encoded frame.
Recommendation: Default
no-progress
Default: Not Set
Disables the progress indicator while encoding.
Recommendation: Default
quiet
Default: Not Set
Enables Quiet Mode, silencing status messages from x264.
Recommendation: Default
psnr
Default: Not Set
Enables PSNR calculations that are reported on completion at the cost of a small decrease in speed.
Recommendation: Default
ssim
Default: Not Set
Enables SSIM calculations that are reported on completion at the cost of a small decrease in speed.
Recommendation: Default
threads
Default: auto
Enables parallel encoding by using more than 1 thread to increase speed on multi-core systems. Previously, this threading was based on a slice encoding model, where the video was encoded in n slices (where n == threads). Since r607 this model was changed to sliceless threading, where the 'atomic unit' is now macroblock rows. The rest of this section refers to the latter system only.
The quality loss from multiple threads is mostly negligible unless using very high numbers of threads (say, above 16).
x264 currently has an internal limit on the number of threads set at 128, realistically you should never set it this high.
Recommendation: Default
See also: thread input
sliced-threads
Default: off
Enables slice-based threading. This threading method produces worse results than the default method both compression and efficiency-wise, but adds no encoding latency.
Recommendation: Default (off), unless you are doing some sort of realtime streaming or low latency is important.
thread-input
Default: Set if threads > 1.
Decodes the input video in a separate thread to the encoding process.
Recommendation: Default.
sync-lookahead
Default: auto
Sets the number of frames to be used as a buffer for threaded lookahead. Maximum Value is 250. Automatically disabled during the 2nd or greater pass.
Other than 0 meaning that the thread is disabled, the minimum allowed buffer size is the automatic one: bframes+threads
Recommendation: Default
non-deterministic
Default: Not Set
Slightly improve quality of SMP, at the cost of repeatability. It will enable multi-threaded mv and uses the entire lookahead buffer in slicetype decisions when slicetype is threaded.
Not for general use.
Recommendation: Default
See also: threads
asm
Default: auto
Override automatic CPU detection. Useful for debugging or troubleshooting.
Recommendation: Default
no-asm
Default: Not Set
Disables all CPU optimisations. Useful for debugging or troubleshooting.
Recommendation: Default
visualize
Default: Not Set
Enables Macroblock Type visualizations over the encoded video. Useful for frame by frame debugging or analysis.
Requires an X11-capable system to be able to compile with and use visualizations.
Recommendation: Default
dump-yuv
Default: Not Set
Dumps the reconstructed YUV frames to the specified file. Useful mostly for debugging. Not for general use.
Recommendation: Default
sps-id
Default: Not Set
Set SPS (sequence parameter set) and PPS (picture parameter set) id numbers. Not for general use.
Recommendation: Default
aud
Default: Not Set
Use access unit delimiters.
Recommendation: Default, unless encoding for Blu-ray, in which case set this option.
force-cfr
Default: Not Set
If using ffms2 or lavf demuxers, timecodes are copied from the input file, provided the output file is not raw. This option disables this, and forces x264 to generate it's own.
Recommendation: Default
Known Patches and Effects
x264_hrd_pulldown.#_interlace
Current Official Version: x264_hrd_pulldown.18_interlace
Adds in new options bff, nal-hrd, and pulldown. Alters the option tff
Patch is used for adding in features to further increase hardware compliancy.
Known Issues
- still under testing to determine stability
- speculated to be developed upon guesswork
nal-hrd
Default: Not Set
Add NAL HRD parameters to the output stream; used for HD-DVD and Blu-ray compliancy. Depends on vbv-bufsize and vbv-maxrate to be set to be active.
Recommendation: Default
See also: vbv-bufsize, vbv-maxrate, aud
tff & bff
Default: Not Set
Denote the stream as having either Top Field First or Bottom Field First interlacing schemes. Also implicitly adds in nal-hrd parameters to identify the stream as specified.
Recommendation: Default
See also: nal-hrd
pulldown
Default: Not Set
Used to apply a pulldown pattern to alter the output stream's framerate from the input stream's; usually also to meet hardware compliancy.
Recommendation: Default
See Also
- Linux Encodingx264 encoding options guide. Very applicable to x264 options. Mostly written by x264 developer Dark Shikari.
- Lord Mulder's x264 in Avidemux guide. Written by this guy. If you don't mind incredible verboseness and a lot of text written like this it's worth a look.

