X264参数设定详细解释

来源:互联网 发布:淘宝开店靠谱吗 编辑:程序博客网 时间:2024/04/28 09:30
x264 core:65 r1074M b6bb3d4
Syntax: x264 [options] -o outfile infile [widthxheight]
语法(命令行写法):x264 [参数] -o 输出文件名 输入文件名 [宽x高]
范例:
x264 --crf 26 --ref 3 --mixed-refs --bframes 3 --b-adapt 2 --b-pyramid --weightb --deblock -1:-1 --trellis 2 --partitions all --8x8dct --me umh --threads auto --thread-input --aud --progress --no-psnr --no-ssim -o output.mp4 input.avs 720x480 

Infile can be raw YUV 4:2:0 (in which case resolution is required),
or YUV4MPEG 4:2:0 (*.y4m),
or AVI or Avisynth if compiled with AVIS support (yes).
输入文件可以是RAW YUV 4:2:0(在某些情况下分辨率是必需的)
或者YUV4MPEG 4:2:0 (*.y4m)
或者AVI 或 Avisynth(后面的yes说明支持AVS输入)

Outfile type is selected by filename:
.264 -> Raw bytestream
.mkv -> Matroska
.mp4 -> MP4 if compiled with GPAC support (yes)
输出文件类型由输出文件名指定:
.264 -> Raw 格式
.mkv -> MKV格式
.MP4 -> MP4格式(yes说明支持MP4输出)Options:
可选参数:

-h, --help List the more commonly used options
--longhelp List all options
-h, --help 显示常用参数
--longhelp 显示全部参数
注:-h,--help代表-h与--help两者都可以,-h是简化写法
举个例子:
x264 -h与x264 --help两者效果等价

——————————————————————————————————————

Frame-type options:
帧-类型选项:


-I, --keyint <integer> Maximum GOP size [250]
说明:指定两个IDR帧之间的最大间隔,默认250
推荐值:默认或者FPS的10倍
范例:--keyint 300
注:[250]代表默认值为250
提示:若想使用默认值,不使用参数即可

-i, --min-keyint <integer> Minimum GOP size [25]
说明:指定两个IDR帧之间的最小间隔,默认25
推荐值:默认或者FPS的大小
范例:--min-keyint 30

问题:如何查看FPS?
http://mediainfo.sourceforge.net/zh-CN
去上面的网站下载mediainfo查看

--scenecut <integer> How aggressively to insert extra I-frames [40]
说明:指定强制使用IDR帧的阀值,值越大强度越高,默认为40
推荐值:默认
范例:--scenecut 40

--pre-scenecut Faster, less precise scenecut detection.
Required and implied by multi-threading.
说明:效果同scenecut,速度比scenecut快,但是精度稍低,默认设定为当threads>1时,永远使用--pre-scenecut
推荐值:默认

-b, --bframes <integer> Number of B-frames between I and P [0]
说明:设定I帧与P帧之间的最大B帧数量,范围0~16
推荐值:3-6
范例:--bframes 3

--b-adapt Adaptive B-frame decision method [1]
Higher values may lower threading efficiency.
- 0: Disabled
- 1: Fast
- 2: Optimal (slow with high --bframes)
说明:B帧自适应方法,默认为1
- 0: 关闭
- 1: 高速
- 2: 最优化 (--bframes的值越高速度越慢)
推荐值:2
范例:--b-adapt 2

--b-bias <integer> Influences how often B-frames are used [0]
说明:影响B帧使用的频繁程度,默认为0
推荐值:0
范例:--b-bias 0

--b-pyramid Keep some B-frames as references
说明:允许其它帧参考B帧,默认不使用
推荐值:开启
范例:--b-pyramid

--no-cabac Disable CABAC
说明:关闭CABAC,默认不使用

-r, --ref <integer> Number of reference frames [1]
说明:设定参考帧的数量,范围0~16,默认值为1,过大的值可能导致无法硬解,参考以下公式计算良好硬解的最大参考帧
最大参考帧数量计算公式:maximum ref = 12288 * 1024 / ( width * height * 1.5)
推荐值:3-6
范例:--ref 3

--no-deblock Disable loop filter
说明:关闭deblock filter,默认不使用
推荐值:默认
范例:--no-deblock

-f, --deblock <alpha:beta> Loop filter AlphaC0 and Beta parameters [0:0]
说 明:设定deblock filter参数,alpha为Deblocking strength,beta为Deblockingthreshold,值越大deblocking效果越好,画面越干净,但是会损失一些细节并有些许模 糊,反之亦然,上下限不要超过-3,3,默认0,0
推荐值:默认
范例:--deblock 0:0

--interlaced Enable pure-interlaced mode
说明:隔行编码模式,默认关闭
范例:--interlaced

——————————————————————————————————————

Ratecontrol:
压缩比控制:


-q, --qp <integer> Set QP (0=lossless) [26]
说明:固定量化模式,值越小质量越好,默认为26,qp = crf + --qcomp 1
推荐值:使用crf,见crf部分
范例:--qp 26

-B, --bitrate <integer> Set bitrate (kbit/s)
说明:目标码率模式,生成的视频码率大小为指定的bitrate的值,一般搭配--pass使用
推荐值:720P以下码率为800-2100kbps之间,720P为3-6Mbps,1080P为8-15Mbps以上
范例:--bitrate 1000

--crf <float> Quality-based VBR (nominal QP)
说明:固定压缩因子模式,值越小质量越好,一般搭配--qcomp使用
推荐值:16-26
范例:--crf 26

--qcomp <float> QP curve compression: 0.0 => CBR, 1.0 => CQP [0.60]
说明:压缩曲线,范围为0~1之间,数值越小曲线越平坦,与crf搭配使用,默认为0.6
推荐值:默认
范例:--qcomp 0.6

--vbv-maxrate <integer> Max local bitrate (kbit/s) [0]
说明:设定VBV模式的最大码率,如果需要硬解必须开启VBV模式,默认为0
范例:--vbv-maxrate 50000

--vbv-bufsize <integer> Enable CBR and set size of the VBV buffer (kbit) [0]
说明:设定VBV缓冲区的最大尺寸,其大小一般由硬件设备决定,默认为0
范例:--vbv-bufsize 50000

--vbv-init <float> Initial VBV buffer occupancy [0.9]
说明:设定VBV缓冲区的初始填充尺寸,默认为0.9
范例:--vbv-init 0.9

--qpmin <integer> Set min QP [10]
说明:设定qp的下限,默认为10
范例:--qpmin 10

--qpmax <integer> Set max QP [51]
说明:设定qp的上限,默认为51
范例:--qpmax 51

--qpstep <integer> Set max QP step [4]
说明:设定qp的最大步长,默认为4
范例:--qpstep 4

--ratetol <float> Allowed variance of average bitrate [1.0]
说明:允许最终码率偏离指定平均码率的百分比,只在1pass中起作用,默认为1.0
范例:--ratetol 1.0

--ipratio <float> QP factor between I and P [1.40]
说明:设定I帧相对于P帧的量化比
推荐值:默认
范例:--ipratio 1.40

--pbratio <float> QP factor between P and B [1.30]
说明:设定P帧相对于B帧的量化比
推荐值:默认
范例:--ipratio 1.30

--chroma-qp-offset <integer> QP difference between chroma and luma [0]
说明:chroma 与 luma 的QP差异值,这个值会随着--psy-rd的使用自动调整为-2
推荐值:默认
范例:--chroma-qp-offset 0

--aq-mode <integer> AQ method [1]
- 0: Disabled
- 1: Variance AQ (complexity mask)
说明:自适应量化方法,可以改善某些场景过于模糊等问题,默认开启

- 0: 关闭
- 1: 可变AQ
推荐值:默认
范例:--aq-mode 1

--aq-strength <float> Reduces blocking and blurring in flat and
textured areas. [1.0]
- 0.5: weak AQ
- 1.5: strong AQ
说明:指定AQ的强度,减小低细节宏块的量化值,默认1.0
- 0.5: 较弱的AQ
- 1.5: 较强的AQ
推荐值:默认
范例:--aq-strength 1.0

-p, --pass <1|2|3> Enable multipass ratecontrol
- 1: First pass, creates stats file
- 2: Last pass, does not overwrite stats file
- 3: Nth pass, overwrites stats file
说明:多重压缩模式,1 pass 或N pass生成stats文件,2pass调用生成的stats文件对压缩进行优化,更合理的分配码率,一般没必要进行N pass
- 1: 第1 pass,生成stats文件
- 2: 最终pass,不覆盖stats文件
- 3: 第N pass,覆盖stats文件
推荐值:2
范例:--pass 2

--stats <string> Filename for 2 pass stats ["x264_2pass.log"]
说明:指定stats文件名,默认为"x264_2pass.log"
推荐值:默认
范例:--stats "x264_2pass.log"

--cplxblur <float> Reduce fluctuations in QP (before curve compression) [20.0]
说明:减小QP的波动(在曲线压缩以前),范围0~999
推荐值:默认
范例:--cplxblur 20

--qblur <float> Reduce fluctuations in QP (after curve compression) [0.5]
说明:减小QP的波动(在曲线压缩之后),范围0~99
推荐值:默认
范例:--qblur 0.5

--zones <zone0>/<zone1>/... Tweak the bitrate of some regions of the video
Each zone is of the form
<start frame>,<end frame>,<option>
where <option> is either
q=<integer> (force QP)
or b=<float> (bitrate multiplier)
说明:调整视频中某一范围内的码率
每个区域已以下形式出现
<开始帧>,<结束帧>,<option>
<option> 为下面的任意一个
q=<integer> (强制 QP)
或 b=<float> (指定bitrate)
范例:--zone 0,1000,qp=30/30000,32000,b=0.5

--qpfile <string> Force frametypes and QPs
说明:强制指定帧类型与QP

推荐值:默认


Analysis:
分析:

-A, --partitions <string> Partitions to consider ["p8x8,b8x8,i8x8,i4x4"]
- p8x8, p4x4, b8x8, i8x8, i4x4
- none, all
(p4x4 requires p8x8. i8x8 requires --8x8dct.)
说明:宏块分割方式,默认["p8x8,b8x8,i8x8,i4x4"]
- p8x8, p4x4, b8x8, i8x8, i4x4
- none, all
(p4x4 需要 p8x8. i8x8 需要 --8x8dct.)
推荐值:默认
范例:--partitions "p8x8,b8x8,i8x8,i4x4"

--direct <string> Direct MV prediction mode ["spatial"]
- none, spatial, temporal, auto
说明:Direct预测方法,默认"spatial"
- none, spatial, temporal, auto
推荐值:"auto"
范例:--direct "auto"

--direct-8x8 <-1|0|1> Direct prediction size [1]
- 0: 4x4
- 1: 8x8
- -1: smallest possible according to level
说明:Direct预测大小,默认为 -1
- 0: 4x4
- 1: 8x8
- -1: 根据Level确定一个最小值
范例:--direct 1

-w, --weightb Weighted prediction for B-frames
说明:允许对B帧进行加权预测
范例:--weightb

--me <string> 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)
说明:全像素动态预测方法,越往下精度越高,速度越慢,默认"hex"
- dia: 菱形搜索, 半径 1 (高速)
- hex: 六边形搜索, 半径 2
- umh: 不规则多边形搜索
- esa: 全面搜索
- tesa: hadamard变换全面搜索 (最慢)
推荐值:"umh"
范例:--me "umh"

--merange <integer> Maximum motion vector search range [16]
说明:最大动态矢量搜索范围,结合--me使用,对于dia与hex,允许的范围为4~16,umh以上可以超过16,值越大编码速度越慢,默认为16
范例:--merange 16

--mvrange <integer> Maximum motion vector length [-1 (auto)]
说明:最大动态矢量长度
推荐值:默认
范例:--mvrange -1 

--mvrange-thread <int> Minimum buffer between threads [-1 (auto)]
说明:线程之间的最小缓冲区大小
推荐值:默认
范例:--mvrange-thread -1 

-m, --subme <integer> Subpixel motion estimation and mode decision [6]
- 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
说明:子像素动态预测模式策略,值越大效果越好,速度越慢,默认6
- 0: 仅fullpel (不推荐)
- 1: SAD模式策略, 1 qpel迭代
- 2: SATD模式策略
- 3-5: 依次qpel增加
- 6: I/P-帧RD模式策略
- 7: 所有帧RD模式策略
- 8: I/P-帧RD refinement模式策略
- 9: 所有帧RD refinement模式策略
推荐值:6以上
范例:--subme 7

--psy-rd Strength of psychovisual optimization ["1.0:0.0"]
#1: RD (requires subme>=6)
#2: Trellis (requires trellis, experimental)
说明:视觉优化,--psy-rd 1.0:0.0 代表#1为1.0,#2为0.0,#2还在测试阶段,默认1.0:0.0
#1: RD (需要subme>=6)
#2: Trellis (需要trellis, 测试阶段)
推荐值:#1 (0~1.0),#2 0.0
范例:--psy-rd 1.0:0.0

--mixed-refs Decide references on a per partition basis
说明:对每个宏块区进行参考帧判断,开启后可以提升质量,但会降低速度
推荐值:开启
范例:--mixed-refs

--no-chroma-me Ignore chroma in motion estimation
说明:在动态预测中忽略chroma
推荐值:默认
范例:--no-chroma-me

-8, --8x8dct Adaptive spatial transform size
说明:自适应空间变换大小
推荐值:使用
范例:--8x8dct

-t, --trellis <integer> Trellis RD quantization. Requires CABAC. [0]
- 0: disabled
- 1: enabled only on the final encode of a MB
- 2: enabled on all mode decisions
说明:Trllis RD量化.需要CABAC,值越大速度越慢,默认 0
- 0:关闭
- 1:基于宏块
- 2:在所有模式策略中使用
推荐值:1
范例:--trellis 1

--no-fast-pskip Disables early SKIP detection on P-frames
说明:关闭早期的P帧快速检测,开启可以提升质量,但会减低一些速度,默认不使用
推荐值:使用
范例:--no-fast-pskip

--no-dct-decimate Disables coefficient thresholding on P-frames
说明:关闭P帧的系数阀值,默认不使用
推荐值:默认
范例:--no-dct-decimate

--nr <integer> Noise reduction [0]
说明:降噪,默认0
推荐值:默认
范例:--nr 0

--deadzone-inter <int> Set the size of the inter luma quantization deadzo
ne [21]
--deadzone-intra <int> Set the size of the intra luma quantization deadzo
ne [11]
Deadzones should be in the range 0 - 32.
说明:设定inter/intra luma deadzone 量化值的大小,范围0 - 32
推荐值:默认
范例:--deadzone-inter 21 --deadzone-intra 11

--cqm <string> Preset quant matrices ["flat"]
- jvt, flat
说明:预设量化矩阵 - jvt, flat
推荐值:默认
范例:--cqm "flat"

--cqmfile <string> Read custom quant matrices from a JM-compatible file
Overrides any other --cqm* options.
说明:读取自定义JM兼容的量化矩阵文件,无视任何以--cqm开头的参数
范例:--cqm "mycqm"

--cqm4 <list> Set all 4x4 quant matrices
Takes a comma-separated list of 16 integers.
说明:设定所有4x4量化矩阵,它是一张以逗号分割的16个整数的表
范例:--cqm "16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16"

--cqm8 <list> Set all 8x8 quant matrices
Takes a comma-separated list of 64 integers.
说明:设定所有8x8量化矩阵,它是一张以逗号分割的64个整数的表
范例:参考--cqm4

--cqm4i, --cqm4p, --cqm8i, --cqm8p
Set both luma and chroma quant matrices
说明:设定luma与chroma的量化矩阵
范例:参考--cqm4

--cqm4iy, --cqm4ic, --cqm4py, --cqm4pc
Set individual quant matrices
说明:单独设定量化矩阵
范例:参考--cqm4

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.
视频可用性信息:
VUI设置在编码的时候不会用到,它仅仅作用于回放设备。详情查看doc/vui.txt.由此带来的风险由使用者自己承担.

--overscan <string> Specify crop overscan setting ["undef"]
- undef, show, crop
说明:指定切边过扫描设定,默认"undef"
- undef, show, crop
范例:--overscan "undef"

--videoformat <string> Specify video format ["undef"]
- component, pal, ntsc, secam, mac, undef
说明:指定视频格式,默认"undef"
- component, pal, ntsc, secam, mac, undef
范例:--videoformat "undef"

--fullrange <string> Specify full range samples setting ["off"]
- off, on
说明:指定颜色全范围样本设置,默认"off"
- off,on
范例:--fullrange "off"

--colorprim <string> Specify color primaries ["undef"]
- undef, bt709, bt470m, bt470bg
smpte170m, smpte240m, film
说明:指定原色,默认"undef"
- undef, bt709, bt470m, bt470bg
smpte170m, smpte240m, film
范例:--colorprim "bt470bg"

--transfer <string> Specify transfer characteristics ["undef"]
- undef, bt709, bt470m, bt470bg, linear,
log100, log316, smpte170m, smpte240m
说明:指定转换特征,默认"undef"
- undef, bt709, bt470m, bt470bg, linear,
log100, log316, smpte170m, smpte240m
范例:--transfer "undef"

--colormatrix <string> Specify color matrix setting ["undef"]
- undef, bt709, fcc, bt470bg
smpte170m, smpte240m, GBR, YCgCo
说明:指定颜色矩阵,默认"undef"
- undef, bt709, bt470m, bt470bg, linear,
log100, log316, smpte170m, smpte240m
范例:--colormatrix "undef"

--chromaloc <integer> Specify chroma sample location (0 to 5) [0]
说明:指定chroma sample location,源为mpeg2与mpeg4时保持默认,源为mpeg1时设为1,范围为0~5,默认 0
范例:--chromaloc 0

——————————————————————————————————————

Input/Output:
输入/输出:


-o, --output Specify output file
说明:指定输出文件
范例:--output output.mp4

--sar width:height Specify Sample Aspect Ratio
说明:指定sar,sar的详细解释看这里
http://www.sonature.com.cn/thread-572-1-1.html
范例:--sar 40:33

--fps <float|rational> Specify framerate
说明:指定视频的帧率
推荐值:默认
范例:--fps 29.97

--seek <integer> First frame to encode
说明:指定编码起始帧,此帧之前的帧将被抛弃
范例:--seek 100

--frames <integer> Maximum number of frames to encode
说明:指定编码总帧数
范例:--frames 200

--level <string> Specify level (as defined by Annex A)
说明:指定level,如无特别需要,尽量让level处于4.1以下
范例:--level 4.1

-v, --verbose Print stats for each frame
说明:显示所有帧的状态
范例:--verbose

--progress Show a progress indicator while encoding
说明:编码时显示进度条
范例:--progress

--quiet Quiet Mode
说明:安静模式
范例:--quiet

--no-psnr Disable PSNR computation
说明:不计算PSNR
范例:--no-psnr

--no-ssim Disable SSIM computation
说明:不计算SSIM
范例:--no-ssim

--threads <integer> Parallel encoding
说明:指定编码线程数
范例:--threads 8

--thread-input Run Avisynth in its own thread
说明:在单独线程上运行AVS
范例:--thread-input

--non-deterministic Slightly improve quality of SMP, at the cost of repeatability
说明:略微提升SMP质量
范例:--non-deterministic

--asm <integer> Override CPU detection
说明:覆盖CPU检测数据
范例:--asm 120

--no-asm Disable all CPU optimizations
说明:不使用所有CPU优化参数
范例:--no-asm

--visualize Show MB types overlayed on the encoded video
说明:显示编码视频的宏块类型
范例:--visualize

--dump-yuv <string> Save reconstructed frames
说明:保存重建的帧
范例:--dump-yuv "文件名"

--sps-id <integer> Set SPS and PPS id numbers [0]
说明:设定SPS与PPS ID号
范例:--sps-id 0

--aud Use access unit delimiters
说明:使用访问单元限定符
范例:--aud


0 0