Skip to content

x264

currentMigrated from docs/encoders/x264.mdx at 37c3317fd058; modified for Encode Wiki · CC BY-SA 4.0

videolan/x264

code.videolan.org
No commits since Sep 2025

x264, the best and fastest H.264 encoder

Last commit
License
GPL-2.0-or-later

x264 is VideoLAN’s open-source encoder for H.264 / AVC, available as a command-line program and as the libx264 library used by FFmpeg, HandBrake and most other tools. It is fast, well threaded and keeps fine detail and grain well thanks to its psychovisual optimizations. Because H.264 decodes on practically everything, x264 is still the default choice when compatibility matters more than compression efficiency.

x264 has no numbered releases. Builds are identified by API core and revision, for example core 165 r3222; development now consists mostly of occasional platform and assembly work. Most FFmpeg builds include libx264; standalone binaries are published at artifacts.videolan.org, and the source is at code.videolan.org/videolan/x264.

Pick the slowest preset you can tolerate, pick a CRF, and adjust from there:

Terminal window
x264 --preset slow --crf 20 -o output.mkv input.y4m
ffmpeg -i input.mkv -c:v libx264 -preset slow -crf 20 -c:a copy output.mkv

The standalone program reads Y4M and raw YUV (plus anything else if built with libavformat or FFMS2 input) and writes raw .264, Matroska, FLV, or MP4 when built with L-SMASH or GPAC. It handles video only, so mux audio and subtitles afterwards. To feed it from FFmpeg, pipe Y4M:

Terminal window
ffmpeg -i input.mkv -f yuv4mpegpipe - | x264 --demuxer y4m --preset slow --crf 20 -o output.264 -

In FFmpeg, -preset, -tune, -crf, -profile:v, -g (keyint) and -b:v map to x264 settings; anything else goes through -x264-params as colon-separated key=value pairs (use , inside values such as psy-rd=1.0,0.15). FFmpeg leaves x264’s own defaults alone unless you set something, so a plain -c:v libx264 encode is preset medium, CRF 23.

ModeUse it forHow
CRFAlmost everything: constant perceived quality, file size follows the content--crf 20 / -crf 20
Two-pass bitrateHitting a file size--pass 1 then --pass 2 with the same --bitrate
VBVStreaming, Blu-ray or device limits on peak bitrate--vbv-maxrate + --vbv-bufsize, with CRF or bitrate
Constant QPLossless (--qp 0) and testing only--qp N

CRF defaults to 23. Lower is higher quality and larger files; ±6 roughly halves or doubles the bitrate. Most encodes land between about 16 (close to transparent) and 23. CRF values are not comparable between encoders, and changing the preset or tune changes the size you get at a given CRF. With 10-bit output the CRF scale extends down to -12.

Two-pass gives the best quality for a target size. x264 runs the first pass with faster analysis settings automatically (--slow-firstpass disables that), and the first-pass output can be thrown away:

Terminal window
x264 --preset slow --pass 1 --bitrate 4000 -o /dev/null input.y4m
x264 --preset slow --pass 2 --bitrate 4000 -o output.mkv input.y4m

With FFmpeg, use -pass 1/-pass 2 with -b:v 4M; the first pass can skip audio and discard its output with -an -f null /dev/null.

VBV limits the peak bitrate a decoder’s buffer has to absorb. --vbv-maxrate is in kbit/s and --vbv-bufsize in kbit, so --vbv-maxrate 10000 --vbv-bufsize 20000 caps the rate at 10 Mbit/s over a 2-second buffer. Combined with CRF (“capped CRF”) it keeps CRF’s quality targeting until a scene would exceed the cap. In FFmpeg the equivalents are -maxrate and -bufsize.

Levels. Without --level, x264 signals whatever level the settings need. At 1080p, --preset veryslow uses 16 reference frames and produces level 5.1, which some TVs and hardware players reject. Set --level 4.1 (or whatever your target device needs) and x264 caps the reference count to fit.

Presets run ultrafast, superfast, veryfast, faster, fast, medium (default), slow, slower, veryslow and placebo. Each step trades speed for compression efficiency. veryslow is the usual practical ceiling; placebo is much slower for a negligible gain. Choose a preset first, then tune individual options.

Tunes adjust settings for a type of content and are applied after the preset; your own options override both. Only one of the psy tunes (film, animation, grain, stillimage, psnr, ssim) can be used at a time, though fastdecode and zerolatency can be combined with one.

TuneChanges (from x264 —fullhelp)Use for
film--deblock -1:-1 --psy-rd <unset>:0.15Live action
animation--bframes +2 --deblock 1:1 --psy-rd 0.4:<unset> --aq-strength 0.6, doubled refsCel animation, flat colours
grain--aq-strength 0.5 --no-dct-decimate --deadzone-inter 6 --deadzone-intra 6 --deblock -2:-2 --ipratio 1.1 --pbratio 1.1 --psy-rd <unset>:0.25 --qcomp 0.8Keeping heavy film grain at high bitrates
stillimage--aq-strength 1.2 --deblock -3:-3 --psy-rd 2.0:0.7Slideshows, still content
psnr / ssimDisable psy optimizations (--no-psy; AQ off for psnr, auto-variance AQ for ssim)Metric benchmarking only
fastdecode--no-cabac --no-deblock --no-weightb --weightp 0Weak decoders, very high bitrates
zerolatency--bframes 0 --force-cfr --no-mbtree --sync-lookahead 0 --sliced-threads --rc-lookahead 0Real-time streaming, video calls

Defaults are for preset medium with no tune. Most people only touch a few of these: a common high-quality starting point for live action is --preset veryslow --tune film --crf 18, adding --aq-mode 3 if dark scenes band. See Psychovisual optimization for the background.

OptionDefaultWhat it does and when to change it
--psy-rd <rd>:<trellis>1.0:0.0Psy-RD (first value) favours keeping the source’s energy and detail; psy-trellis (second) does the same in quantization. Film and grain tunes raise psy-trellis to 0.15/0.25. Lower psy-RD (e.g. 0.4 in the animation tune) for flat content. Psy-RD needs --subme 6 or higher; psy-trellis needs trellis.
--aq-mode10 off, 1 variance AQ, 2 auto-variance, 3 auto-variance with a bias toward dark scenes. Mode 3 is a popular choice to reduce banding and blocking in dark areas; it spends more bits on dark scenes.
--aq-strength1.0How strongly AQ moves bits between flat and textured areas. Animation tune lowers it to 0.6, grain to 0.5.
--deblock <alpha>:<beta>0:0Loop-filter strength offsets. Negative values keep more detail and grain at high bitrates (film -1:-1, grain -2:-2); positive values smooth more (animation 1:1).
--no-mbtree / --qcompMB-tree on, qcomp 0.60MB-tree gives more bits to areas that later frames reference and fewer to areas that quickly disappear. It is a large efficiency gain, but it can flatten grain and dark detail. Raising --qcomp weakens it (MB-tree strength is 5 × (1 − qcomp)); the grain tune uses 0.8. Turning MB-tree off entirely costs a lot of efficiency.
--bframes3Maximum consecutive B-frames. 8 (veryslow) is common for high-efficiency encodes; animation benefits from more.
--b-adapt1B-frame placement: 0 fixed, 1 fast, 2 optimal. Use 2 (slower and up) with high --bframes.
--ref3Reference frames, up to 16. More helps efficiency, especially for animation, but costs speed and raises the required level.
--mehexMotion search: dia, hex, umh, esa, tesa. umh (slower and up) is the usual quality choice; esa/tesa are rarely worth the time.
--subme7Subpixel motion estimation and mode decision, 0–11. 10 needs --trellis 2 and AQ; 11 disables all early terminations.
--merange16Motion search range for umh/esa/tesa. 24 in veryslow; raise it for fast motion or high resolutions.
--rc-lookahead40Frames analysed for frame types and MB-tree. 60 in slower and up; more costs memory and speed.
--trellis1Rate-distortion optimized quantization: 0 off, 1 final decision, 2 all decisions.
--keyint / --min-keyint250 / autoMaximum and minimum keyframe interval in frames. Lower --keyint gives faster seeking and is often set to about 10 × the frame rate.
--open-gopOffLets frames reference across keyframe boundaries for slightly better compression. Leave it off if the stream will be cut or segmented at keyframes.
--threadsauto1.5 × the logical CPU count by default. x264 scales well, so only lower it to leave CPU for other work.

Current x264 builds include 8-bit and 10-bit in one binary (--output-depth 10, or -pix_fmt yuv420p10le in FFmpeg). 10-bit H.264 (High 10 profile) reduces banding and compresses a little better, which made it popular for anime releases, but few hardware decoders, phones, TVs or browsers support it. Use 10-bit x264 only when the video will be played in software players.

FFmpeg 9.0.2 still refuses to write more than 8 bits to Y4M without -strict -1, so a 10-bit pipe looks like this:

Terminal window
ffmpeg -i input.mkv -pix_fmt yuv420p10le -strict -1 -f yuv4mpegpipe - | x264 --demuxer y4m --output-depth 10 --preset slow --crf 20 -o output.mkv -

x264 also encodes 4:0:0, 4:2:2 and 4:4:4 (--output-csp, or the input pixel format in FFmpeg) and RGB (--output-csp rgb, or libx264rgb in FFmpeg). These use the High 4:2:2 and High 4:4:4 Predictive profiles, which have even less decoder support.

--qp 0 (-qp 0 in FFmpeg) is lossless and uses the High 4:4:4 Predictive profile. --crf 0 is also lossless with 8-bit output but not with 10-bit, so use --qp 0. Slower presets make smaller lossless files.

Lossless x264 is a very fast intermediate format. --preset ultrafast gives the fastest encoding and decoding, and adding --tune fastdecode speeds decoding further; --preset superfast produces noticeably smaller files and is still very fast. For archival, compare against FFV1, which is designed for that job and has wider support in archival tools.

Every long option in the x264 r3222 command-line parser, grouped as in x264 --fullhelp, with short forms where they exist. Defaults are x264’s own with --preset medium and no tune or profile; presets, tunes and --profile change many of them. Apart from --range, the Video Usability Info options only write metadata and never convert the picture. Optional demuxers, muxers and OpenCL support depend on how your binary was built.

Help
OptionDefaultDescription
-h, --help—Print the basic options and exit.
--longhelp—Print the basic and common advanced options and exit.
--fullhelp—Print every option, including what each preset and tune changes, and exit.
Presets
OptionDefaultDescription
--profilenone (lowest profile the settings need)Restrict output to an H.264 profile: baseline, main, high, high10, high422 or high444. Turns off tools the profile forbids, overriding other options, and fails if the bit depth, chroma format or lossless mode needs a higher profile.
--presetmediumSpeed/compression trade-off: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. Applied first; any option you set explicitly overrides it. Use the slowest preset you can afford.
--tunenoneAdjust for the source or use case. Psy tunes (pick at most one): film, animation, grain, stillimage, psnr, ssim. Others: fastdecode, zerolatency. Combine with commas, e.g. film,fastdecode.
--slow-firstpassoffKeep the full analysis settings in --pass 1. By default the first pass switches to --ref 1 --me dia --partitions none --trellis 0 --no-8x8dct and at most --subme 2 for speed. placebo implies it.
Frame-type options
OptionDefaultDescription
-I, --keyint250Maximum distance between IDR frames, in frames; infinite for none. Lower it for faster seeking or to match a streaming segment length.
-i, --min-keyintauto (keyint/10, at most the frame rate)Minimum distance between IDR frames. A scene cut closer than this to the previous IDR gets a non-IDR I-frame instead. Clamped to keyint/2+1.
--no-scenecutoffDisable scene-cut detection, so keyframes are placed only by --keyint. Same as --scenecut 0.
--scenecut40Scene-cut sensitivity: higher values insert I/IDR frames at more scene changes. 0 disables detection.
--intra-refreshoffReplace IDR keyframes with a column of intra blocks that sweeps across the picture over keyint frames. Evens out frame sizes for low-latency streaming; forces --ref 1, and disables --open-gop.
-b, --bframes3Maximum consecutive B-frames, 0–16. With adaptive B-frames x264 uses fewer where that is cheaper.
--b-adapt1B-frame placement: 0 always use --bframes, 1 fast, 2 optimal (slower, especially with many B-frames).
--b-bias0Bias the adaptive B-frame decision toward (positive) or against (negative) B-frames, −90 to 100.
--b-pyramidnormalLet B-frames be used as references: none, strict (hierarchy allowed by Blu-ray) or normal. Needs at least 2 B-frames.
--open-gopoffLet frames after a keyframe reference frames before it, with recovery-point SEI marking the random-access point. Slightly more efficient; some players and editors handle open GOPs poorly. Needs B-frames.
--no-cabacoffUse CAVLC instead of CABAC entropy coding: larger files, faster decoding. Required for Baseline profile.
-r, --ref3Maximum reference frames, 1–16. More helps compression with diminishing returns and costs speed and decoder memory. If you set --level but not --ref, x264 lowers it to fit the level’s DPB.
--no-deblockoffDisable the in-loop deblocking filter.
-f, --deblock0:0Deblocking strength and threshold offsets as alpha:beta, each −6 to 6. Negative values keep more fine detail and grain, positive values smooth more. A single number sets both.
--slices0 (one slice)Slices per frame. Forces rectangular slices; overridden by --slice-max-size and --slice-max-mbs. Mainly for specs that require slices (Blu-ray, broadcast).
--slices-max0 (no limit)Absolute maximum slices per frame; takes priority over --slice-max-size and --slice-max-mbs.
--slice-max-size0 (off)Maximum slice size in bytes, including NAL overhead. Used to fit slices into network packets.
--slice-max-mbs0 (off)Maximum macroblocks per slice.
--slice-min-mbs0 (off)Minimum macroblocks per slice when slices are split by size or macroblock count.
--tffoffEncode interlaced, top field first. x264 also switches to interlaced coding when the input is flagged interlaced.
--bffoffEncode interlaced, bottom field first.
--constrained-intraoffIntra macroblocks may only predict from intra-coded neighbours. Limits error propagation; costs compression.
--pulldownnoneSoft pulldown: code progressive frames and flag repeated fields/frames with pic_struct. Values: none, 22, 32, 64, double, triple, euro; 32 turns 23.976p into 29.97i. Requires CFR input.
--fake-interlacedoffFlag the stream as interlaced while coding progressive frames. Allows 25p and 30p on Blu-ray, which only permits those rates as interlaced.
--frame-packing-1 (none)Stereo 3D frame-packing SEI: 0 checkerboard, 1 column interleave, 2 row interleave, 3 side by side, 4 top-bottom, 5 frame alternation, 6 2D, 7 tile format.
Ratecontrol
OptionDefaultDescription
-q, --qpnone (CRF mode)Constant-QP mode. Range 0–69 for 8-bit and 0–81 for 10-bit output (10-bit QPs are 12 higher for the same quantizer step); 0 is lossless. Turns off AQ and MB-tree, so CRF compresses better at the same quality.
-B, --bitratenoneAverage bitrate in kbit/s (ABR). Use it with --pass for a target file size, or with VBV for capped streaming; single-pass ABR without VBV is the weakest mode.
--crf23.0Constant rate factor, the default mode: constant quality with variable bitrate. Lower is better quality; +6 roughly halves the bitrate. Range 0–51 for 8-bit and −12–51 for 10-bit output; CRF 0 is lossless only for 8-bit. 17–28 is the usual range.
--rc-lookahead40Frames analysed ahead for frame-type decisions, MB-tree and VBV, up to 250. More helps MB-tree slightly but adds memory and latency. Capped at the larger of --keyint and the VBV buffer duration.
--vbv-maxrate0 (off)VBV maximum rate in kbit/s; needs --vbv-bufsize. With CRF it caps peaks; set it equal to --bitrate for CBR-like output.
--vbv-bufsize0 (off)VBV buffer size in kbit; needs --vbv-maxrate except in ABR mode, where maxrate defaults to the bitrate. Buffer size divided by maxrate is roughly the averaging window in seconds.
--vbv-init0.9Initial VBV buffer fill: values up to 1 are a fraction of --vbv-bufsize, larger values are in kbit.
--crf-maxnoneWith CRF and VBV, the highest rate factor VBV may push to. Stops quality collapsing in hard scenes but can cause VBV underflows.
--qpmin0Lowest QP rate control may use. Raising it saves bits on easy content at the cost of quality there.
--qpmax81 (no cap)Highest QP rate control may use. The default is clamped to x264’s internal maximum for the bit depth (69 for 8-bit, 81 for 10-bit). Lowering it prevents very coarse frames but can break bitrate or VBV targets.
--qpstep4Maximum QP change between consecutive frames, minimum 2.
--ratetol1.0How far ABR may drift from the target bitrate while spreading bits (higher = freer distribution, less exact size); also how aggressively VBV avoids underflow. Accepts inf.
--ipratio1.40QP factor between I- and P-frames: 1.4 makes I-frames about 3 QP lower.
--pbratio1.30QP factor between P- and B-frames. Has no effect with MB-tree on (the default), which sets B-frame QPs itself.
--chroma-qp-offset0Chroma QP offset relative to luma, −12 to 12. x264 adds its own adjustment on top: −2 with psy-rd (−1 below 0.25), another −1 or −2 with psy-trellis, and +6 for 4:4:4 with psy on.
--aq-mode1Adaptive quantization: 0 off, 1 variance AQ, 2 auto-variance, 3 auto-variance biased toward dark scenes. AQ moves bits from detailed to flat areas, reducing banding and blocking; mode 3 helps dark gradients.
--aq-strength1.0AQ strength, 0–3; 0 disables AQ. Tunes set 0.6 (animation), 0.5 (grain) and 1.2 (stillimage).
-p, --passnoneMultipass: 1 writes the stats file, 2 reads it (final pass), 3 reads and rewrites it (middle passes). Use with --bitrate for an exact file size.
--statsx264_2pass.logStats file for --pass. With MB-tree, x264 also writes <file>.mbtree.
--no-mbtreeoffDisable MB-tree, which lowers QP for blocks that later frames reference. MB-tree is a large compression gain; leave it on.
--qcomp0.60Quantizer curve compression, 0–1: 0 is constant bitrate, 1 is constant QP. Also sets MB-tree strength (higher = weaker); 1 disables MB-tree. --tune grain uses 0.8.
--cplxblur20.0Temporal smoothing of frame complexity before the QP curve is applied; reduces QP fluctuation in ABR and multipass.
--qblur0.5Temporal smoothing of QPs after the curve is applied (multipass).
--zonesnonePer-range overrides, separated by /: start,end,q=N (force QP) or start,end,b=F (bitrate multiplier), optionally followed by more option=value settings such as crf= or deblock=. Frame numbers are inclusive.
--qpfilenoneFile of frame type [QP] lines that force frame types (I, i, K, P, B, b) and optional QPs. K is an IDR, or a recovery-point I-frame with --open-gop. Used to put keyframes on chapter or segment boundaries.
Analysis
OptionDefaultDescription
-A, --partitionsp8x8,b8x8,i8x8,i4x4Macroblock partitions searched: p8x8, p4x4, b8x8, i8x8, i4x4, none, all. p4x4 needs p8x8; i8x8 needs 8×8 DCT. slower and above use all.
--directspatialDirect motion-vector prediction in B-frames: none, spatial, temporal or auto (picks per frame; used from slow up).
--no-weightboffDisable weighted prediction in B-frames.
--weightp2Weighted prediction in P-frames, mainly for fades: 0 off, 1 weighted references, 2 also adds duplicate references with different weights. Some players mishandle 2; --bluray-compat limits it to 1.
--mehexInteger-pel motion search: dia (fastest), hex, umh (uneven multi-hexagon, used by slower and veryslow), esa (exhaustive), tesa (exhaustive with Hadamard transform). Beyond umh the gains are tiny.
--merange16Motion search range in pixels, 4–1024. With dia and hex anything above 16 is ignored; veryslow uses 24 with umh.
--mvrange-1 (auto)Maximum vertical motion-vector length in pixels. Auto uses the level’s limit; lower it only for a decoder that needs it.
--mvrange-thread-1 (auto)Minimum row buffer between frame threads, in pixels. Limits how far motion vectors may reach into a frame still being encoded; leave on auto.
-m, --subme7Subpixel refinement and mode decision, 0–11: 1–5 progressively more quarter-pel search, 6 RD mode decision on I/P-frames, 7 on all frames, 8–9 RD refinement, 10 QP-RD (needs --trellis 2 and AQ), 11 full RD. Psy-RD needs 6 or higher.
--psy-rd1.0:0.0Psychovisual strengths as rd:trellis, each 0–10. Psy-RD (needs --subme 6+) keeps detail and grain instead of blurring them; psy-trellis (needs trellis) does the same during quantization. A single number sets psy-RD and zeroes psy-trellis. Tunes: film :0.15, grain :0.25, animation 0.4:, stillimage 2.0:0.7.
--no-psyoffDisable all psychovisual optimizations that lower PSNR and SSIM, including psy-RD and psy-trellis. Used by --tune psnr and --tune ssim; the result looks worse.
--no-mixed-refsoffChoose references per macroblock instead of per 8×8 partition. Slightly faster and less efficient; irrelevant with --ref 1.
--no-chroma-meoffUse only luma in motion search. Slightly faster, slightly worse.
--no-8x8dctoffDisable the adaptive 8×8 transform, a High-profile tool. Main and Baseline profiles turn it off.
-t, --trellis1Trellis (rate-distortion optimized) quantization: 0 off, 1 on the final encode of each macroblock, 2 in all mode decisions (slow and above). Psy-trellis needs it.
--no-fast-pskipoffDisable early skip detection in P-frames. Slower; can help flat areas and gradients. placebo uses it.
--no-dct-decimateoffKeep the small coefficients that DCT decimation would zero in inter blocks. Preserves fine detail and grain at a bit cost; used by --tune grain.
--nr0 (off)Fast noise reduction in the DCT domain, 0–65536. Values of a few hundred are typical; a real denoising filter does a better job.
--deadzone-inter21Inter luma quantization deadzone, 0–32: larger values discard more small coefficients. Only applies where trellis is not used (everything with --trellis 0, mode decisions with --trellis 1). --tune grain sets 6.
--deadzone-intra11Intra luma quantization deadzone, 0–32. Same rules as --deadzone-inter.
--cqmflatQuantization-matrix preset: flat or jvt (the JVT default matrices). Non-flat matrices need High profile.
--cqmfilenoneRead custom matrices from a JM-format file. Overrides all other --cqm* options.
--cqm4flatSet all four 4×4 matrices: 16 comma-separated integers.
--cqm8flatSet all 8×8 matrices: 64 comma-separated integers.
--cqm4i, --cqm4p, --cqm8i, --cqm8pflatSet intra or inter (p) 4×4 or 8×8 matrices for luma and chroma together: 16 or 64 integers.
--cqm4iy, --cqm4ic, --cqm4py, --cqm4pcflatSet one 4×4 matrix (intra/inter × luma/chroma): 16 integers.
Video Usability Info (Annex E)
OptionDefaultDescription
--overscanundefOverscan hint: undef, show or crop.
--videoformatundefAnalog source format flag: component, pal, ntsc, secam, mac or undef.
--rangeauto (from input; pc for RGB)Signalled sample range: tv (limited) or pc (full). If it differs from the input range, the CLI converts the samples.
--colorprimundefColour primaries flag, e.g. bt709, bt470bg, smpte170m, bt2020.
--transferundefTransfer characteristics flag, e.g. bt709, smpte2084 (PQ), arib-std-b67 (HLG).
--colormatrixauto (GBR for RGB, otherwise undef)Matrix coefficients flag, e.g. bt709, bt470bg, smpte170m, bt2020nc.
--chromaloc0Chroma sample location type, 0–5. 0 (left) suits most 4:2:0 video; 2 (top-left) is used for BT.2020/UHD.
--mastering-displaynoneHDR10 mastering display SEI: G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min), chromaticity in 0.00002 units and luminance in 0.0001 cd/m².
--cllnoneContent light level SEI: MaxCLL,MaxFALL in cd/m².
--alternative-transferundefAlternative transfer characteristics SEI, same values as --transfer. Used for HLG: --transfer bt2020-10 --alternative-transfer arib-std-b67.
--nal-hrdnoneWrite HRD parameters and buffering-period/picture-timing SEI: none, vbr or cbr. Requires VBV. Needed for broadcast and Blu-ray; cbr pads with filler and is not allowed in MP4.
--filleroffHard CBR: add filler data so the stream never drops below --vbv-maxrate. Implied by --nal-hrd cbr.
--pic-structoffAlways write pic_struct in picture-timing SEI. Pulldown and interlaced coding write it anyway.
--crop-rect0,0,0,0Add left,top,right,bottom to the bitstream cropping rectangle, so decoders hide those pixels. Values must be multiples of the chroma subsampling.
Input/Output
OptionDefaultDescription
-o, --outputrequiredOutput file. The extension selects the container: .mkv, .flv, .mp4 (needs L-SMASH or GPAC), anything else raw H.264; - writes raw H.264 to stdout.
--muxerautoForce the container: auto, raw, mkv, flv or mp4.
--demuxerautoForce the input reader: auto, raw, y4m, plus avs, lavf and ffms when compiled in.
--input-fmtnoneForce the libavformat input format (lavf builds only).
--input-cspi420 (raw)Pixel format of raw input, e.g. i420, nv12, i422, i444, rgb. Y4M, lavf and ffms inputs carry their own.
--output-cspi420Chroma format to encode: i400, i420, i422, i444 or rgb. The CLI converts other inputs to it, so a 4:2:2 or 4:4:4 source is encoded as 4:2:0 unless you set this.
--input-depth8 (raw)Bit depth of raw input, 8–16. Y4M carries its own.
--output-depth8 (10 in a 10-bit-only build)Encoding bit depth, 8 or 10. Current builds support both in one binary; input of another depth is converted, with dithering when reducing.
--input-rangeautoRange of the input: auto, tv or pc. Overrides what the demuxer reports.
--input-resrequired (raw)Size of raw input as WIDTHxHEIGHT.
--indexnoneIndex file for the ffms demuxer; written on the first run and reused afterwards.
--sarfrom inputSample (pixel) aspect ratio as W:H, e.g. 1:1 or 40:33. Set it for anamorphic video.
--fpsfrom input (25 for raw)Frame rate as a decimal or rational (24000/1001). Forces constant-frame-rate timestamps.
--seek0First input frame to encode (0-based).
--framesallMaximum number of frames to encode.
--levelautoH.264 level to signal, e.g. 4.1, 41 or 1b. Without --ref, x264 reduces the reference count to fit; it only warns about VBV and other limits, so set --vbv-maxrate and --vbv-bufsize for real compliance.
--bluray-compatoffBlu-ray restrictions: at most 3 B-frames and 6 references, strict pyramid, --weightp 1 or lower, AUDs, HRD (vbr), no intra refresh, --min-keyint 1. Combine with the other Blu-ray settings (level, VBV, slices, keyint).
--avcintra-class0 (off)Produce AVC-Intra class 50, 100, 200, 300 or 480 (300 and 480 need --avcintra-flavor sony). Requires a matching resolution, frame rate and pixel format, and overrides most settings.
--avcintra-flavorpanasonicAVC-Intra variant: panasonic or sony (XAVC).
--stitchableoffDon’t optimize headers for the content, so separately encoded segments can be joined.
-v, --verboseoffPrint statistics for every frame (debug log level).
--no-progressoffHide the progress line.
--quietoffSuppress all log output.
--log-levelinfoLog verbosity: none, error, warning, info or debug.
--psnroffCompute and report PSNR. x264 warns that the numbers are invalid unless psy is off and AQ is off (--tune psnr).
--ssimoffCompute and report SSIM. x264 warns unless psy is off and AQ is on (--tune ssim).
--threadsauto (1.5 × logical CPUs)Frame-encoding threads, up to 128. Auto is also limited to one thread per two macroblock rows. Very high counts cost a little compression.
--lookahead-threadsautoThreads for the lookahead; auto derives a count from --threads and the analysis settings.
--sliced-threadsoffThread by slices within a frame instead of by frames: no extra latency, but less efficient. Used by --tune zerolatency.
--thread-inputauto (on with more than one thread)Read and decode input in its own thread.
--sync-lookaheadauto (bframes + 1)Frames buffered between the threaded lookahead and the encoder; 0 disables threaded lookahead for lower latency.
--non-deterministicoffLet frame threads use slightly more information for marginally better quality, at the cost of run-to-run repeatability.
--cpu-independentoffProduce identical output on different CPUs by not letting them pick different algorithms.
--asmautoOverride CPU feature detection with a bitmask or comma-separated names (e.g. sse2,avx2). For debugging.
--no-asmoffDisable all assembly optimizations. Much slower; for debugging.
--opencloffUse OpenCL for the lookahead (OpenCL builds, 8-bit only).
--opencl-clbinnoneFile for caching the compiled OpenCL kernel.
--opencl-device0OpenCL device index.
--dump-yuvnoneWrite reconstructed frames to a raw YUV file, for debugging.
--sps-id0ID written into the SPS and PPS, 0–31.
--audoffWrite access unit delimiters. Some broadcast, transport-stream and Blu-ray targets need them.
--force-cfroffIgnore input timestamps and generate constant-frame-rate ones.
--tcfile-innoneTake timestamps from a Matroska timecode v1 or v2 file for VFR output. Can’t be combined with --fps.
--tcfile-outnoneWrite the input timestamps to a timecode v2 file.
--timebasefrom inputTimebase as num/den. A single integer is the numerator with --tcfile-in and the denominator otherwise. Not allowed with CFR input.
--dts-compressoffRemove the initial delay caused by B-frames by shifting DTS in FLV and MP4 output.
Filtering
OptionDefaultDescription
--vf, --video-filternoneInput filter chain, filters separated by /: crop:left,top,right,bottom, select_every:step,offset1[,...], and resize (scaling, SAR and pixel-format conversion) in builds with libswscale.
Additional accepted flags and aliases
OptionDefaultDescription
-V, --version—Print the version and build configuration and exit.
--no-b-adaptoffSame as --b-adapt 0.
--nfoffOld spelling of --no-deblock.
--filter0:0Old spelling of --deblock.
--interlacedoffEncode interlaced; field order defaults to top field first.
--no-interlacedoffEncode progressive even if the input is flagged interlaced.
--cabaconUse CABAC entropy coding (the default).
--stdoutautoOld alias of --muxer; takes the same values.
--stdinautoOld alias of --demuxer; takes the same values.
--analysep8x8,b8x8,i8x8,i4x4Old spelling of --partitions.
-w, --weightbonWeighted prediction in B-frames (the default).
--psyonPsychovisual optimizations (the default).
--mixed-refsonPer-partition reference selection (the default).
-8, --8x8dctonAdaptive 8×8 transform (the default).
--fast-pskiponEarly P-frame skip detection (the default).
--mbtreeonMB-tree rate control (the default).
--no-sliced-threadson (frame threading)Thread by frames (the default); cancels --sliced-threads.

The private libx264 options in FFmpeg 9.0.2; the last column names the x264 setting each one sets. A default of -1, auto, unset or INT_MIN means not set: FFmpeg passes nothing and x264’s preset value applies, so -crf -1 does not mean CRF −1. Generic FFmpeg options also reach x264: -b:v (--bitrate), -maxrate and -bufsize (VBV), -g (--keyint), -keyint_min, -bf (--bframes), -refs, -qmin, -qmax, -qcomp, -trellis, -me_range, -subq, -threads and the stream’s colour metadata. -x264-params and -x264opts take x264 library settings, not CLI-only options such as --output or --demuxer.

All libx264 private options
OptionTypeDefaultRange / valuesMaps to and meaning
-presetstringmediumstringx264 --preset.
-tunestringunsetstringx264 --tune; combine with commas, e.g. film,fastdecode.
-profilestringunsetstringx264 --profile: baseline, main, high, high10, high422, high444.
-fastfirstpassbooleantrue0 to 1With -pass 1, use x264’s fast first-pass settings. 0 is the same as x264 --slow-firstpass.
-levelstringunsetstringx264 --level, e.g. 4.1.
-passlogfilestringunsetstringSame field as -stats. On the ffmpeg command line this name belongs to the generic two-pass prefix option, which sets stats to <prefix>-<stream index>.log (default ffmpeg2pass-0.log).
-wpredpstringunsetstringx264 --weightp as a string (0, 1, 2). Older duplicate of -weightp, which wins if both are set.
-a53ccbooleantrue0 to 1Write A/53 closed captions from the input frames as SEI.
-x264optsstringunsetstringx264 settings as key=value:key=value; a bare key means key=1. Applied after the other wrapper options. An unknown key or bad value stops the encode.
-crffloat-1-1 to FLT_MAXx264 --crf. Takes priority over -b:v and -qp; ignored with -pass 2.
-crf_maxfloat-1-1 to FLT_MAXx264 --crf-max. Ignored with -pass 2.
-qpint-1-1 to INT_MAXx264 --qp (constant QP, 0 = lossless). Used only if -crf is not set; ignored with -pass 2.
-aq-modeint-1-1 to INT_MAX; none=0, variance=1, autovariance=2, autovariance-biased=3x264 --aq-mode.
-aq-strengthfloat-1-1 to FLT_MAXx264 --aq-strength.
-psybooleanauto-1 to 1x264 --psy (0 = --no-psy).
-psy-rdstringunsetstringx264 --psy-rd, as rd:trellis.
-rc-lookaheadint-1-1 to INT_MAXx264 --rc-lookahead.
-weightbbooleanauto-1 to 1x264 --weightb.
-weightpint-1-1 to INT_MAX; none=0, simple=1, smart=2x264 --weightp.
-ssimbooleanauto-1 to 1x264 --ssim: report SSIM at the end. For PSNR use the generic -flags +psnr.
-intra-refreshbooleanauto-1 to 1x264 --intra-refresh.
-bluray-compatbooleanauto-1 to 1x264 --bluray-compat; setting it also forces constant-frame-rate timestamps.
-b-biasintINT_MININT_MIN to INT_MAXx264 --b-bias; INT_MIN means not set.
-b-pyramidint-1-1 to INT_MAX; none=0, strict=1, normal=2x264 --b-pyramid.
-mixed-refsbooleanauto-1 to 1x264 --mixed-refs.
-8x8dctbooleanauto-1 to 1x264 --8x8dct.
-fast-pskipbooleanauto-1 to 1x264 --fast-pskip.
-audbooleanauto-1 to 1x264 --aud.
-mbtreebooleanauto-1 to 1x264 --mbtree.
-deblockstringunsetstringx264 --deblock (alpha:beta).
-cplxblurfloat-1-1 to FLT_MAXx264 --cplxblur.
-partitionsstringunsetp8x8, p4x4, b8x8, i8x8, i4x4, none, allx264 --partitions, comma-separated.
-direct-predint-1-1 to INT_MAX; none=0, spatial=1, temporal=2, auto=3x264 --direct.
-slice-max-sizeint-1-1 to INT_MAXx264 --slice-max-size, in bytes.
-statsstringunsetstringx264 --stats. The ffmpeg CLI fills it in from -passlogfile when you use -pass.
-nal-hrdint-1-1 to INT_MAX; none=0, vbr=1, cbr=2x264 --nal-hrd; needs -maxrate and -bufsize. cbr is not allowed in MP4.
-avcintra-classint-1-1 to 480x264 --avcintra-class; 300 and 480 also select the Sony flavor.
-me_methodint-1-1 to 4; dia=0, hex=1, umh=2, esa=3, tesa=4x264 --me; same field as -motion-est.
-motion-estint-1-1 to 4; dia=0, hex=1, umh=2, esa=3, tesa=4x264 --me.
-forced-idrbooleanfalse-1 to 1Code forced keyframes (e.g. from -force_key_frames) as IDR frames. Otherwise they are x264 keyframes, which are non-IDR recovery points with open GOP.
-coderintdefault-1 to 1; default=-1, cavlc=0, cabac=1, vlc=0, ac=1Entropy coder: cabac/ac or cavlc/vlc. default keeps x264’s choice (CABAC unless the profile or tune disables it).
-b_strategyint-1-1 to 2x264 --b-adapt (0, 1, 2).
-chromaoffsetint0INT_MIN to INT_MAXx264 --chroma-qp-offset; 0 leaves x264’s value.
-sc_thresholdint-1INT_MIN to INT_MAXx264 --scenecut; 0 disables scene-cut detection.
-noise_reductionint-1INT_MIN to INT_MAXx264 --nr.
-udu_seibooleanfalse0 to 1Write user-data-unregistered SEI from the input frames’ side data.
-x264-paramsdictionaryunsetkey=value listx264 settings as key=value:key=value, using x264’s long option names without -- (e.g. no-mbtree=1). Applied last, so it overrides everything else. An invalid entry only logs a warning and is skipped.
-mb_infobooleanfalse0 to 1Pass per-macroblock hints (AVVideoHint side data) to x264. Only useful for applications using the API.