Scroll to navigation

X264(1) User Commands X264(1)

NAME

x264 - fast h264 encoder

DESCRIPTION

x264 core:164 r3095 baee400 Syntax: x264 [options] -o outfile infile

Infile can be raw (in which case resolution is required),

or YUV4MPEG (*.y4m), or Avisynth if compiled with support (yes). or libav* formats if compiled with lavf support (yes) or ffms support (yes).

Outfile type is selected by filename:

.264 -> Raw bytestream .mkv -> Matroska .flv -> Flash Video .mp4 -> MP4 if compiled with GPAC or L-SMASH support (gpac)

Output bit depth: 8/10

OPTIONS

List basic options
List more options
List all options

Example usage:

Constant quality mode:
x264 --crf 24 -o <output> <input>
Two-pass with a bitrate of 1000kbps:
x264 --pass 1 --bitrate 1000 -o <output> <input> x264 --pass 2 --bitrate 1000 -o <output> <input>
Lossless:
x264 --qp 0 -o <output> <input>
Maximum PSNR at the cost of speed and visual quality:
x264 --preset placebo --tune psnr -o <output> <input>
Constant bitrate at 1000kbps with a 2 second-buffer:
x264 --vbv-bufsize 2000 --bitrate 1000 -o <output> <input>

Presets:

Force the limits of an H.264 profile Overrides all settings. - baseline:
--cqm flat --weightp 0 No interlaced. No lossless.
--no-8x8dct --cqm flat No lossless.
No lossless.
No lossless. Support for bit depth 8-10.
No lossless. Support for bit depth 8-10. Support for 4:2:0/4:2:2 chroma subsampling.
Support for bit depth 8-10. Support for 4:2:0/4:2:2/4:4:4 chroma subsampling.
Use a preset to select encoding settings [medium] Overridden by user settings. - ultrafast:
--bframes 0 --no-cabac --no-deblock --no-mbtree --me dia --no-mixed-refs --partitions none --rc-lookahead 0 --ref 1 --scenecut 0 --subme 0 --trellis 0 --no-weightb --weightp 0
--no-mbtree --me dia --no-mixed-refs --partitions i8x8,i4x4 --rc-lookahead 0 --ref 1 --subme 1 --trellis 0 --weightp 1
--no-mixed-refs --rc-lookahead 10 --ref 1 --subme 2 --trellis 0 --weightp 1
--no-mixed-refs --rc-lookahead 20 --ref 2 --subme 4 --weightp 1
--rc-lookahead 30 --ref 2 --subme 6 --weightp 1
Default settings apply.
--direct auto --rc-lookahead 50 --ref 5 --subme 8 --trellis 2
--b-adapt 2 --direct auto --me umh --partitions all --rc-lookahead 60 --ref 8 --subme 9 --trellis 2
--b-adapt 2 --bframes 8 --direct auto --me umh --merange 24 --partitions all --ref 16 --subme 10 --trellis 2 --rc-lookahead 60
--bframes 16 --b-adapt 2 --direct auto --slow-firstpass --no-fast-pskip --me tesa --merange 24 --partitions all --rc-lookahead 60 --ref 16 --subme 11 --trellis 2
Tune the settings for a particular type of source or situation
Multiple tunings are separated by commas. Only one psy tuning can be used at a time. - film (psy tuning):
- animation (psy tuning):
--psy-rd 0.4:<unset> --aq-strength 0.6 --ref {Double if >1 else 1}
--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.8
--aq-strength 1.2 --deblock -3:-3 --psy-rd 2.0:0.7
--aq-mode 0 --no-psy
--aq-mode 2 --no-psy
--no-cabac --no-deblock --no-weightb --weightp 0
--bframes 0 --force-cfr --no-mbtree --sync-lookahead 0 --sliced-threads --rc-lookahead 0
Don't force these faster settings with --pass 1: --no-8x8dct --me dia --partitions none --ref 1 --subme {2 if >2 else unchanged} --trellis 0 --fast-pskip

Frame-type options:

-I, --keyint <integer or "infinite"> Maximum GOP size [250]

Minimum GOP size [auto]
Disable adaptive I-frame decision
How aggressively to insert extra I-frames [40]
Use Periodic Intra Refresh instead of IDR frames
Number of B-frames between I and P [3]
Adaptive B-frame decision method [1] Higher values may lower threading efficiency. - 0: Disabled - 1: Fast - 2: Optimal (slow with high --bframes)
Influences how often B-frames are used [0]
Keep some B-frames as references [normal] - none: Disabled - strict: Strictly hierarchical pyramid - normal: Non-strict (not Blu-ray compatible)
Use recovery points to close GOPs Only available with b-frames
Disable CABAC
Number of reference frames [3]
Disable loop filter
Loop filter parameters [0:0]
Number of slices per frame; forces rectangular slices and is overridden by other slicing options
Absolute maximum slices per frame; overrides slice-max-size/slice-max-mbs when necessary

--slice-max-size <integer> Limit the size of each slice in bytes

--slice-max-mbs <integer> Limit the size of each slice in macroblocks (max)

--slice-min-mbs <integer> Limit the size of each slice in macroblocks (min)

Enable interlaced mode (top field first)
Enable interlaced mode (bottom field first)
Enable constrained intra prediction.
Use soft pulldown to change frame rate - none, 22, 32, 64, double, triple, euro (requires cfr input)
Flag stream as interlaced but encode progressive. Makes it possible to encode 25p and 30p Blu-Ray streams. Ignored in interlaced mode.
- 0: checkerboard - pixels are alternatively from L and R - 1: column alternation - L and R are interlaced by column - 2: row alternation - L and R are interlaced by row - 3: side by side - L is on the left, R on the right - 4: top bottom - L is on top, R on bottom - 5: frame alternation - one view per frame - 6: mono - 2D frame without any frame packing - 7: tile format - L is on top-left, R split across

Ratecontrol:

Force constant QP (0-81, 0=lossless)
Set bitrate (kbit/s)
Quality-based VBR (-12-51) [23.0]

--rc-lookahead <integer> Number of frames for frametype lookahead [40]

--vbv-maxrate <integer> Max local bitrate (kbit/s) [0]

--vbv-bufsize <integer> Set size of the VBV buffer (kbit) [0]

Initial VBV buffer occupancy [0.9]
With CRF+VBV, limit RF to this value May cause VBV underflows!
Set min QP [0]
Set max QP [81]
Set max QP step [4]
Tolerance of ABR ratecontrol and VBV [1.0]
QP factor between I and P [1.40]
QP factor between P and B [1.30]
QP difference between chroma and luma [0]
AQ method [1] - 0: Disabled - 1: Variance AQ (complexity mask) - 2: Auto-variance AQ - 3: Auto-variance AQ with bias to dark scenes
Reduces blocking and blurring in flat and textured areas. [1.0]
Enable multipass ratecontrol - 1: First pass, creates stats file - 2: Last pass, does not overwrite stats file - 3: Nth pass, overwrites stats file
Filename for 2 pass stats ["x264_2pass.log"]
Disable mb-tree ratecontrol.
QP curve compression [0.60]
Reduce fluctuations in QP (before curve compression) [20.0]
Reduce fluctuations in QP (after curve compression) [0.5]
Tweak the bitrate of regions of the video Each zone is of the form
<start frame>,<end frame>,<option>
where <option> is either
or b=<float> (bitrate multiplier)
Force frametypes and QPs for some or all frames Format of each line: framenumber frametype QP QP is optional (none lets x264 choose). Frametypes: I,i,K,P,B,b.
QPs are restricted by qpmin/qpmax.

Analysis:

Partitions to consider ["p8x8,b8x8,i8x8,i4x4"] - p8x8, p4x4, b8x8, i8x8, i4x4, none, all (p4x4 requires p8x8. i8x8 requires --8x8dct.)
Direct MV prediction mode ["spatial"] - none, spatial, temporal, auto
Disable weighted prediction for B-frames
Weighted prediction for P-frames [2] - 0: Disabled - 1: Weighted refs - 2: Weighted refs + Duplicates
Integer pixel motion estimation method ["hex"] - dia: diamond search, radius 1 (fast) - hex: hexagonal search, radius 2 - umh: uneven multi-hexagon search - esa: exhaustive search - tesa: hadamard exhaustive search (slow)
Maximum motion vector search range [16]
Maximum motion vector length [-1 (auto)]
Minimum buffer between threads [-1 (auto)]
Subpixel motion estimation and mode decision [7] - 0: fullpel only (not recommended) - 1: SAD mode decision, one qpel iteration - 2: SATD mode decision - 3-5: Progressively more qpel - 6: RD mode decision for I/P-frames - 7: RD mode decision for all frames - 8: RD refinement for I/P-frames - 9: RD refinement for all frames - 10: QP-RD - requires trellis=2, aq-mode>0 - 11: Full RD: disable all early terminations
Strength of psychovisual optimization ["1.0:0.0"] #1: RD (requires subme>=6) #2: Trellis (requires trellis, experimental)
Disable all visual optimizations that worsen both PSNR and SSIM.
Don't decide references on a per partition basis
Ignore chroma in motion estimation
Disable adaptive spatial transform size
Trellis RD quantization. [1] - 0: disabled - 1: enabled only on the final encode of a MB - 2: enabled on all mode decisions
Disables early SKIP detection on P-frames
Disables coefficient thresholding on P-frames
Noise reduction [0]
Set the size of the inter luma quantization deadzone [21]
Set the size of the intra luma quantization deadzone [11] Deadzones should be in the range 0 - 32.
Preset quant matrices ["flat"] - flat, jvt
Read custom quant matrices from a JM-compatible file Overrides any other --cqm* options.
Set all 4x4 quant matrices Takes a comma-separated list of 16 integers.
Set all 8x8 quant matrices Takes a comma-separated list of 64 integers.
Set both luma and chroma quant matrices
Set individual quant matrices

Video Usability Info (Annex E): The VUI settings are not used by the encoder but are merely suggestions to the playback equipment. See doc/vui.txt for details. Use at your own risk.

Specify crop overscan setting ["undef"] - undef, show, crop
Specify video format ["undef"] - component, pal, ntsc, secam, mac, undef
Specify color range ["auto"] - auto, tv, pc
Specify color primaries ["undef"] - undef, bt709, bt470m, bt470bg, smpte170m,
smpte431, smpte432
Specify transfer characteristics ["undef"] - undef, bt709, bt470m, bt470bg, smpte170m,
iec61966-2-4, bt1361e, iec61966-2-1, bt2020-10, bt2020-12, smpte2084, smpte428, arib-std-b67
Specify color matrix setting ["???"] - undef, bt709, fcc, bt470bg, smpte170m,
smpte2085, chroma-derived-nc, chroma-derived-c, ICtCp
Specify chroma sample location (0 to 5) [0]
for primaries, white point, and display brightness
Specify 'max_content,max_frame_average' content light levels
characteristics ["undef"]
- same values as --transfer
Signal HRD information (requires vbv-bufsize) - none, vbr, cbr (cbr not allowed in .mp4)
Force hard-CBR and generate filler (implied by --nal-hrd cbr)
Force pic_struct in Picture Timing SEI
Add 'left,top,right,bottom' to the bitstream-level cropping rectangle

Input/Output:

Specify output file
Specify output container format ["auto"] - auto, raw, mkv, flv, mp4
Specify input container format ["auto"] - auto, raw, y4m, avs, lavf, ffms
Specify input file format (requires lavf support)
Specify input colorspace format for raw input - valid csps for `raw' demuxer:
yuyv, uyvy, i444, yv24, bgr, bgra, rgb
yuv420p, yuyv422, rgb24, bgr24, yuv422p, yuv444p, yuv410p, yuv411p, gray, monow, monob, pal8, yuvj420p, yuvj422p, yuvj444p, uyvy422, uyyvyy411, bgr8, bgr4, bgr4_byte, rgb8, rgb4, rgb4_byte, nv12, nv21, argb, rgba, abgr, bgra, gray16be, gray16le, yuv440p, yuvj440p, yuva420p, rgb48be, rgb48le, rgb565be, rgb565le, rgb555be, rgb555le, bgr565be, bgr565le, bgr555be, bgr555le, vaapi_moco, vaapi_idct, vaapi_vld, yuv420p16le, yuv420p16be, yuv422p16le, yuv422p16be, yuv444p16le, yuv444p16be, dxva2_vld, rgb444le, rgb444be, bgr444le, bgr444be, ya8, bgr48be, bgr48le, yuv420p9be, yuv420p9le, yuv420p10be, yuv420p10le, yuv422p10be, yuv422p10le, yuv444p9be, yuv444p9le, yuv444p10be, yuv444p10le, yuv422p9be, yuv422p9le, gbrp, gbrp9be, gbrp9le, gbrp10be, gbrp10le, gbrp16be, gbrp16le, yuva422p, yuva444p, yuva420p9be, yuva420p9le, yuva422p9be, yuva422p9le, yuva444p9be, yuva444p9le, yuva420p10be, yuva420p10le, yuva422p10be, yuva422p10le, yuva444p10be, yuva444p10le, yuva420p16be, yuva420p16le, yuva422p16be, yuva422p16le, yuva444p16be, yuva444p16le, vdpau, xyz12le, xyz12be, nv16, nv20le, nv20be, rgba64be, rgba64le, bgra64be, bgra64le, yvyu422, ya16be, ya16le, gbrap, gbrap16be, gbrap16le, qsv, mmal, d3d11va_vld, cuda, 0rgb, rgb0, 0bgr, bgr0, yuv420p12be, yuv420p12le, yuv420p14be, yuv420p14le, yuv422p12be, yuv422p12le, yuv422p14be, yuv422p14le, yuv444p12be, yuv444p12le, yuv444p14be, yuv444p14le, gbrp12be, gbrp12le, gbrp14be, gbrp14le, yuvj411p, bayer_bggr8, bayer_rggb8, bayer_gbrg8, bayer_grbg8, bayer_bggr16le, bayer_bggr16be, bayer_rggb16le, bayer_rggb16be, bayer_gbrg16le, bayer_gbrg16be, bayer_grbg16le, bayer_grbg16be, xvmc, yuv440p10le, yuv440p10be, yuv440p12le, yuv440p12be, ayuv64le, ayuv64be, videotoolbox_vld, p010le, p010be, gbrap12be, gbrap12le, gbrap10be, gbrap10le, mediacodec, gray12be, gray12le, gray10be, gray10le, p016le, p016be, d3d11, gray9be, gray9le, gbrpf32be, gbrpf32le, gbrapf32be, gbrapf32le, drm_prime, opencl, gray14be, gray14le, grayf32be, grayf32le, yuva422p12be, yuva422p12le, yuva444p12be, yuva444p12le, nv24, nv42, vulkan, y210be, y210le, x2rgb10le, x2rgb10be
Specify output colorspace ["i420"] - i400, i420, i422, i444, rgb

--input-depth <integer> Specify input bit depth for raw input

--output-depth <integer> Specify output bit depth

Specify input color range ["auto"] - auto, tv, pc
Specify input resolution (width x height)
Filename for input index file
Specify Sample Aspect Ratio
Specify framerate
First frame to encode
Maximum number of frames to encode
Specify level (as defined by Annex A)
Enable compatibility hacks for Blu-ray support
- 50, 100, 200, 300, 480
- panasonic, sony
Don't optimize headers based on video content Ensures ability to recombine a segmented encode
Print stats for each frame
Don't show the progress indicator while encoding
Quiet Mode
Specify the maximum level of logging ["info"] - none, error, warning, info, debug
Enable PSNR computation
Enable SSIM computation
Force a specific number of threads

--lookahead-threads <integer> Force a specific number of lookahead threads

Low-latency but lower-efficiency threading
Run Avisynth in its own thread

--sync-lookahead <integer> Number of buffer frames for threaded lookahead

Slightly improve quality of SMP, at the cost of repeatability
Ensure exact reproducibility across different cpus, as opposed to letting them select different algorithms
Override CPU detection
Disable all CPU optimizations
Enable use of OpenCL

--opencl-clbin <string> Specify path of compiled OpenCL kernel cache

--opencl-device <integer> Specify OpenCL device ordinal

Save reconstructed frames
Set SPS and PPS id numbers [0]
Use access unit delimiters
Force constant framerate timestamp generation
Force timestamp generation with timecode file
Output timecode v2 file from input timestamps
Specify timebase numerator and denominator
<integer>
Specify timebase numerator for input timecode file or specify timebase denominator for other input
Eliminate initial delay with container DTS hack

Filtering:

--vf, --video-filter <filter0>/<filter1>/... Apply video filtering to the input file

Filter options may be specified in <filter>:<option>=<value> format.
Available filters: crop:left,top,right,bottom
removes pixels from the edges of the frame
resize:[width,height][,sar][,fittobox][,csp][,method]
resizes frames based on the given criteria: - resolution only: resizes and adapts sar to avoid stretching - sar only: sets the sar and resizes to avoid stretching - resolution and sar: resizes to given resolution and sets the sar - fittobox: resizes the video based on the desired constraints
- width, height, both
- fittobox and sar: same as above except with specified sar - csp: convert to the given csp. syntax: [name][:depth]
- valid csp names [keep current]: i400, i420, yv12, nv12, nv21, i422, yv16, nv16, yuyv, uyvy, i444, yv24, bgr, bgra, rgb - depth: 8 or 16 bits per pixel [keep current]
note: not all depths are supported by all csps. - method: use resizer method ["bicubic"]
- fastbilinear, bilinear, bicubic, experimental, point, - area, bicublin, gauss, sinc, lanczos, spline
select_every:step,offset1[,...]
apply a selection pattern to input frames step: the number of frames in the pattern offsets: the offset into the step to select a frame see: http://avisynth.nl/index.php/Select#SelectEvery

(libswscale 5.9.100) (libavformat 58.76.100) (ffmpegsource 3.0.1.0) (gpac 2.0) built on Jun 10 2022, gcc: 11.3.0 x264 configuration: --chroma-format=all libx264 configuration: --chroma-format=all x264 license: GPL version 2 or later libswscale/libavformat/ffmpegsource license: GPL version 2 or later

June 2022 Videolan project