X264(1)
π NAME π
okay so bestie, meet x264 β it's a fast h264 encoder, and it is so much. π This one's a User Commands page, iykyk.
π DESCRIPTION π
The version vibe check first, because you'll see it everywhere: x264 core:164 r3108 31e19f9. And the whole syntax situation is literally this:
x264 [options] -o outfile infile
Now, your infile can be a few different things, and one of them has a catch, so pay attention bestie:
- raw β and if it's raw, you have to give a resolution, that's not optional
- YUV4MPEG (
*.y4m) - Avisynth if compiled with support (yes)
- libav* formats if compiled with lavf support (yes) or ffms support (yes)
Your outfile type? It's giving "read my filename and guess" and honestly, slay:
.264-> Raw bytestream.mkv-> Matroska.flv-> Flash Video.mp4-> MP4 if compiled with GPAC or L-SMASH support (no)
Output bit depth: 8/10 π¦
π OPTIONS π
-h,--helpβ lists the basic options, baby steps, we love her--longhelpβ lists more options--fullhelpβ lists all the options, every single one, no crumbs
Example usage, because examples ate and left no crumbs:
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 π
--profile <string>β forces the limits of an H.264 profile. It overrides all settings, she's that girl. πbaseline:--no-8x8dct --bframes 0 --no-cabac --cqm flat --weightp 0β no interlaced. No lossless.main:--no-8x8dct --cqm flatβ no lossless.high: no lossless.high10: no lossless. Support for bit depth 8-10.high422: no lossless. Support for bit depth 8-10. Support for 4:2:0/4:2:2 chroma subsampling.high444: support for bit depth 8-10. Support for 4:2:0/4:2:2/4:4:4 chroma subsampling.
--preset <string>β uses a preset to select encoding settings [medium]. Overridden by user settings, so if you tweak stuff after, your tweaks win. β¨ultrafast:--no-8x8dct --aq-mode 0 --b-adapt 0 --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 0superfast:--no-mbtree --me dia --no-mixed-refs --partitions i8x8,i4x4 --rc-lookahead 0 --ref 1 --subme 1 --trellis 0 --weightp 1veryfast:--no-mixed-refs --rc-lookahead 10 --ref 1 --subme 2 --trellis 0 --weightp 1faster:--no-mixed-refs --rc-lookahead 20 --ref 2 --subme 4 --weightp 1fast:--rc-lookahead 30 --ref 2 --subme 6 --weightp 1medium: default settings apply.slow:--direct auto --rc-lookahead 50 --ref 5 --subme 8 --trellis 2slower:--b-adapt 2 --direct auto --me umh --partitions all --rc-lookahead 60 --ref 8 --subme 9 --trellis 2veryslow:--b-adapt 2 --bframes 8 --direct auto --me umh --merange 24 --partitions all --ref 16 --subme 10 --trellis 2 --rc-lookahead 60placebo:--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 <string>β tunes the settings for a particular type of source or situation. Overridden by user settings. Multiple tunings get separated by commas, and only one psy tuning can be used at a time, so pick a lane bestie. πΈfilm(psy tuning):--deblock -1:-1 --psy-rd <unset>:0.15animation(psy tuning):--bframes {+2} --deblock 1:1 --psy-rd 0.4:<unset> --aq-strength 0.6 --ref {Double if >1 else 1}grain(psy tuning):--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.8stillimage(psy tuning):--aq-strength 1.2 --deblock -3:-3 --psy-rd 2.0:0.7psnr(psy tuning):--aq-mode 0 --no-psyssim(psy tuning):--aq-mode 2 --no-psyfastdecode:--no-cabac --no-deblock --no-weightb --weightp 0zerolatency:--bframes 0 --force-cfr --no-mbtree --sync-lookahead 0 --sliced-threads --rc-lookahead 0
--slow-firstpassβ 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]-i,--min-keyint <integer>β minimum GOP size [auto]--no-scenecutβ disables the adaptive I-frame decision--scenecut <integer>β how aggressively to insert extra I-frames [40]--intra-refreshβ uses Periodic Intra Refresh instead of IDR frames-b,--bframes <integer>β number of B-frames between I and P [3]--b-adapt <integer>β adaptive B-frame decision method [1]. Higher values may lower threading efficiency.- 0: Disabled
- 1: Fast
- 2: Optimal (slow with high
--bframes)
--b-bias <integer>β influences how often B-frames are used [0]--b-pyramid <string>β keeps some B-frames as references [normal]none: Disabledstrict: Strictly hierarchical pyramidnormal: Non-strict (not Blu-ray compatible)
--open-gopβ uses recovery points to close GOPs. Only available with b-frames.--no-cabacβ disables CABAC-r,--ref <integer>β number of reference frames [3]--no-deblockβ disables loop filter-f,--deblock <alpha:beta>β loop filter parameters [0:0]--slices <integer>β number of slices per frame; forces rectangular slices and is overridden by other slicing options--slices-max <integer>β absolute maximum slices per frame; overrides slice-max-size/slice-max-mbs when necessary--slice-max-size <integer>β limits the size of each slice in bytes--slice-max-mbs <integer>β limits the size of each slice in macroblocks (max)--slice-min-mbs <integer>β limits the size of each slice in macroblocks (min)--tffβ enables interlaced mode (top field first)--bffβ enables interlaced mode (bottom field first)--constrained-intraβ enables constrained intra prediction.--pulldown <string>β uses soft pulldown to change frame rate:none,22,32,64,double,triple,euro(requires cfr input)--fake-interlacedβ flags the stream as interlaced but encodes progressive. Makes it possible to encode 25p and 30p Blu-Ray streams. Ignored in interlaced mode.--frame-packing <integer>β for stereoscopic videos, defines the frame arrangement:- 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 π
-q,--qp <integer>β forces constant QP (0-81, 0=lossless)-B,--bitrate <integer>β sets bitrate (kbit/s)--crf <float>β 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>β sets size of the VBV buffer (kbit) [0]--vbv-init <float>β initial VBV buffer occupancy [0.9]--crf-max <float>β with CRF+VBV, limits RF to this value. May cause VBV underflows!
β οΈ bestie, that "May cause VBV underflows!" is not a joke. Be careful with --crf-max. π
--qpmin <integer>β sets min QP [0]--qpmax <integer>β sets max QP [81]--qpstep <integer>β sets max QP step [4]--ratetol <float>β tolerance of ABR ratecontrol and VBV [1.0]--ipratio <float>β QP factor between I and P [1.40]--pbratio <float>β QP factor between P and B [1.30]--chroma-qp-offset <integer>β QP difference between chroma and luma [0]--aq-mode <integer>β AQ method [1]- 0: Disabled
- 1: Variance AQ (complexity mask)
- 2: Auto-variance AQ
- 3: Auto-variance AQ with bias to dark scenes
--aq-strength <float>β reduces blocking and blurring in flat and textured areas. [1.0]-p,--pass <integer>β enables multipass ratecontrol- 1: First pass, creates stats file
- 2: Last pass, does not overwrite stats file
- 3: Nth pass, overwrites stats file
--stats <string>β filename for 2 pass stats ["x264_2pass.log"]--no-mbtreeβ disables mb-tree ratecontrol.--qcomp <float>β QP curve compression [0.60]--cplxblur <float>β reduces fluctuations in QP (before curve compression) [20.0]--qblur <float>β reduces fluctuations in QP (after curve compression) [0.5]--zones <zone0>/<zone1>/...β tweaks the bitrate of regions of the video. Each zone is of the form:<start frame>,<end frame>,<option>where<option>is eitherq=<integer>(force QP)- or
b=<float>(bitrate multiplier)
--qpfile <string>β forces 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.K=<I or i>depending on open-gop setting. QPs are restricted by qpmin/qpmax.
β Analysis β
-A,--partitions <string>β partitions to consider ["p8x8,b8x8,i8x8,i4x4"]p8x8,p4x4,b8x8,i8x8,i4x4,none,all(p4x4 requires p8x8. i8x8 requires--8x8dct.)
--direct <string>β direct MV prediction mode ["spatial"]:none,spatial,temporal,auto--no-weightbβ disables weighted prediction for B-frames--weightp <integer>β weighted prediction for P-frames [2]- 0: Disabled
- 1: Weighted refs
- 2: Weighted refs + Duplicates
--me <string>β integer pixel motion estimation method ["hex"]dia: diamond search, radius 1 (fast)hex: hexagonal search, radius 2umh: uneven multi-hexagon searchesa: exhaustive searchtesa: hadamard exhaustive search (slow)
--merange <integer>β maximum motion vector search range [16]--mvrange <integer>β maximum motion vector length [-1 (auto)]--mvrange-thread <int>β Minimum buffer between threads. Default is-1(auto), because bestie we love an auto setting π-m,--subme <integer>β Subpixel motion estimation and mode decision, default7. The vibes ladder, from most basic to most extra:0: fullpel only (not recommended β do not, fr fr)1: SAD mode decision, one qpel iteration2: SATD mode decision3-5: Progressively more qpel6: RD mode decision for I/P-frames7: RD mode decision for all frames8: RD refinement for I/P-frames9: RD refinement for all frames10: QP-RD β requirestrellis=2,aq-mode>011: Full RD β disables all early terminations, the main character of subme options β¨
--psy-rd <float:float>β Strength of psychovisual optimization, default"1.0:0.0". The first value is RD (requiressubme>=6), the second is Trellis (requirestrellis, and it's experimental, so likeβ¦ proceed with caution π«Ά).--no-psyβ Disable all visual optimizations that worsen both PSNR and SSIM.--no-mixed-refsβ Don't decide references on a per partition basis.--no-chroma-meβ Ignore chroma in motion estimation.--no-8x8dctβ Disable adaptive spatial transform size.-t,--trellis <integer>β Trellis RD quantization. Default1.0: disabled1: enabled only on the final encode of a MB2: enabled on all mode decisions
--no-fast-pskipβ Disables early SKIP detection on P-frames.--no-dct-decimateβ Disables coefficient thresholding on P-frames.--nr <integer>β Noise reduction. Default0.--deadzone-inter <int>β Set the size of the inter luma quantization deadzone. Default21.--deadzone-intra <int>β Set the size of the intra luma quantization deadzone. Default11. Heads up bestie: deadzones should be in the range0-32.--cqm <string>β Preset quant matrices. Default"flat". Options:flat,jvt.--cqmfile <string>β Read custom quant matrices from a JM-compatible file. This overrides any other--cqm*options, no cap.--cqm4 <list>β Set all 4x4 quant matrices. Takes a comma-separated list of 16 integers.--cqm8 <list>β Set all 8x8 quant matrices. Takes a comma-separated list of 64 integers.--cqm4i,--cqm4p,--cqm8i,--cqm8p <list>β Set both luma and chroma quant matrices.--cqm4iy,--cqm4ic,--cqm4py,--cqm4pc <list>β Set individual quant matrices.
Video Usability Info (Annex E): The VUI settings are not used by the encoder β they're merely suggestions to the playback equipment. See doc/vui.txt for details. Use at your own risk. π
--overscan <string>β Specify crop overscan setting. Default"undef". Options:undef,show,crop.--videoformat <string>β Specify video format. Default"undef". Options:component,pal,ntsc,secam,mac,undef.--range <string>β Specify color range. Default"auto". Options:auto,tv,pc.--colorprim <string>β Specify color primaries. Default"undef". Options:undef,bt709,bt470m,bt470bg,smpte170m,smpte240m,film,bt2020,smpte428,smpte431,smpte432.--transfer <string>β Specify transfer characteristics. Default"undef". Options:undef,bt709,bt470m,bt470bg,smpte170m,smpte240m,linear,log100,log316,iec61966-2-4,bt1361e,iec61966-2-1,bt2020-10,bt2020-12,smpte2084,smpte428,arib-std-b67.--colormatrix <string>β Specify color matrix setting. Default"???". Options:undef,bt709,fcc,bt470bg,smpte170m,smpte240m,GBR,YCgCo,bt2020nc,bt2020c,smpte2085,chroma-derived-nc,chroma-derived-c,ICtCp.--chromaloc <integer>β Specify chroma sample location (0to5). Default0.--mastering-display <string>β Specify'G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)'for primaries, white point, and display brightness.--cll <string>β Specify'max_content,max_frame_average'content light levels.--alternative-transfer <string>β Specify an alternative transfer characteristics. Default"undef". Same values as--transferβ¨--nal-hrd <string>β Signal HRD information (requiresvbv-bufsize). Options:none,vbr,cbr(cbris not allowed in.mp4).--fillerβ Force hard-CBR and generate filler (implied by--nal-hrd cbr).--pic-structβ Forcepic_structin Picture Timing SEI.--crop-rect <string>β Add'left,top,right,bottom'to the bitstream-level cropping rectangle.
π¬ Input/Output π¬
-o,--output <string>β Specify output file.--muxer <string>β Specify output container format. Default"auto". Options:auto,raw,mkv,flv.--demuxer <string>β Specify input container format. Default"auto". Options:auto,raw,y4m,avs,lavf,ffms.--input-fmt <string>β Specify input file format (requires lavf support).--input-csp <string>β Specify input colorspace format for raw input. Valid csps for therawdemuxer are:
i400, i420, yv12, nv12, nv21, i422, yv16, nv16, yuyv, uyvy, i444, yv24, bgr, bgra, rgb
And the valid csps for the lavf demuxer are⦠okay bestie, deep breath, this is a lot of them:
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, 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, x2bgr10le, x2bgr10be, p210be, p210le, p410be, p410le, p216be, p216le, p416be, p416le, vuya, rgbaf16be, rgbaf16le, vuyx, p012le, p012be, y212be, y212le, xv30be, xv30le, xv36be, xv36le, rgbf32be, rgbf32le, rgbaf32be, rgbaf32le, p212be, p212le, p412be, p412le, gbrap14be, gbrap14le
--output-csp <string>β Specify output colorspace. Default"i420". Options:i400,i420,i422,i444,rgb.--input-depth <integer>β Specify input bit depth for raw input.--output-depth <integer>β Specify output bit depth.--input-range <string>β Specify input color range. Default"auto". Options:auto,tv,pc.--input-res <intxint>β Specify input resolution (width x height).--index <string>β Filename for input index file.--sar width:heightβ Specify Sample Aspect Ratio.--fps <float|rational>β Specify framerate.--seek <integer>β First frame to encode.--frames <integer>β Maximum number of frames to encode.--level <string>β Specify level (as defined by Annex A).--bluray-compatβ Enable compatibility hacks for Blu-ray support.--avcintra-class <integer>β Use compatibility hacks for AVC-Intra class. Options:50,100,200,300,480.--avcintra-flavor <string>β AVC-Intra flavor. Default"panasonic". Options:panasonic,sony.--stitchableβ Don't optimize headers based on video content. Ensures ability to recombine a segmented encode.-v,--verboseβ Print stats for each frame.--no-progressβ Don't show the progress indicator while encoding.--quietβ Quiet Mode.--log-level <string>β Specify the maximum level of logging. Default"info". Options:none,error,warning,info,debug.--psnrβ Enable PSNR computation.--ssimβ Enable SSIM computation.--threads <integer>β Force a specific number of threads.--lookahead-threads <integer>β Force a specific number of lookahead threads.--sliced-threadsβ Low-latency but lower-efficiency threading.--thread-inputβ Run Avisynth in its own thread.--sync-lookahead <integer>β Number of buffer frames for threaded lookahead.--non-deterministicβ Slightly improve quality of SMP, at the cost of repeatability.--cpu-independentβ Ensure exact reproducibility across different cpus, as opposed to letting them select different algorithms.--asm <integer>β Override CPU detection.--no-asmβ Disable all CPU optimizations.--openclβ Enable use of OpenCL.--opencl-clbin <string>β Specify path of compiled OpenCL kernel cache.--opencl-device <integer>β Specify OpenCL device ordinal.--dump-yuv <string>β Save reconstructed frames.--sps-id <integer>β Set SPS and PPS id numbers. Default0.--audβ Use access unit delimiters.--force-cfrβ Force constant framerate timestamp generation.--tcfile-in <string>β Force timestamp generation with timecode file.--tcfile-out <string>β Output timecode v2 file from input timestamps.--timebase <int/int>β Specify timebase numerator and denominator.<integer>β Specify timebase numerator for input timecode file, or specify timebase denominator for other input.--dts-compressβ 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. β¨
Okay bestie, so the filters you can use? Here's the tea β:
crop:left,top,right,bottomβ removes pixels from the edges of the frame. Bye bye, edges π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.
- valid csp names [keep current]:
- 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
And now for the build tea, bestie π οΈβ¨ β this is the exact version energy:
(libswscale 7.5.100) (libavformat 60.16.100) (ffmpegsource 3.0.1.0)
built on Apr 12 2023, gcc: 13.2.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
So yeah, that's the whole vibe. Made by the Videolan project, January 2024 β this is X264(1), and it ate π No cap, you're gonna slay with these filters. Periodt. π
π¦ where this page comes from
- debian trixie: x264 2:0.164.3108+git31e19f9-2+b1 Β· GPL-2.0-or-later
- ubuntu noble: x264 2:0.164.3108+git31e19f9-1 Β· GPL-2.0-or-later
- ubuntu questing: x264 2:0.164.3108+git31e19f9-2build2
- ubuntu resolute: x264 2:0.165.3222+gitb35605ac-3build1 Β· GPL-2.0-or-later
- ubuntu stonking: x264 2:0.165.3223+git20250910.0480cb0-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms