x264命令行参数解释
- 格式:doc
- 大小:55.50 KB
- 文档页数:16
X264 简单配置详解1、X264 介绍X264 是一个基于 H264 的免费开源的视频编码器,属于后起之秀,采用x264 编解码的视频文件,相比较 xvid 或者其它流行的编解码器转换效率和转换后的画面质量都更加优异,已经受到众多非编人士的青睐。
2、Basic 基本配置preset 预设:通过preset 的参数调节编码速度和质量的平衡。
preset 预设参数类似于 WinRAR 的压缩方式参数,参数值有:UltraFast、SuperFast、VeryFast、Faster、Fast、Medium、Slow、Slower、VerySlow、Placebo。
从快到慢,参数越来越慢,越慢压缩比越高,消耗的时间也越长,默认是 Medium。
Tuning 优化:特别的情况时可以指定片子的类型和视觉优化的参数。
默认值为None,没有特殊要求的不用设置此项。
Tuning 的参数值有:●f ilm:电影、真人类型;●a nimation:动画类型;●g rain:需要保留大量的颗粒时使用;●s tillimage:静态图像编码时使用;●p snr:为提高psnr 做了优化的参数;解释:峰值信噪比(PSNR),是一种评价图像的客观标准。
●s sim:为提高 ssim 做了优化的参数;解释:一种衡量两幅图像相似度的指标,其值越大越好,最大为 1,经常用到图像处理中,特别在图像去噪处理中在图像相似度。
Profile 画质级别:X264 有四种画质级别,分别是baseline, extended, main, high;默认为:Auto(自动),其他参数值的含义:(1)Baseline Profile:基本画质。
支持 I/P 帧,只支持无交错(Progressive)和 CAVLC;(2)Extended profile:进阶画质。
支持 I/P/B/SP/SI 帧,只支持无交错(Progressive)和 CAVLC;(3)Main profile:主流画质。
x264关键参数(草稿)目录前言 (1)Main标签 (2)Zones标签 (6)RC & ME标签 (7)Advanced标签 (10)后记 (13)参考文献与对本文有贡献者 (14)更新记录 (15)前言本文将以MeGUI的界面为引,以x264 r680版为基准,说明x264命令行版的各项参数的设定。
x264参数众多,本文虽以MeGUI为引,但仅仅是按照MeGUI对x264参数的分类与归纳顺序对x264的参数进行说明,因此本文并不讨论MeGUI本身的使用方法。
由于x264与XviD有着众多的相通之处,因此本文将不会对共通的基础概念进行解释。
关于一些关于图像压缩的基础理论知识,请参考笔者的《XviD参数详解》以及《图像压缩原理基础》系列文章。
本文在写作过程中参考了众多资料,得到了很多朋友的支持,参考资料来源以及贡献者的名单在倒数第二节“参考文献与对本文有贡献者”中列出。
限于笔者水平,本文难免有疏漏、错误住处。
若您发现本文不妥之处,请通过下面的联系方式告诉笔者,不胜感激!笔者联系方式:(网站)/nmmbbs(论坛)Main(主要参数)标签在MeGUI的Main标签中,选项被分为General(全局)、Misc(杂项)、Deblocking(编码端解块滤波器)、AVC Profiles(AVC等级)、AVC Level(AVC分层)五个大的部分。
下面,从General开始逐个进行说明。
Mode(编码模式)ABR:Average Bit Rate,平均码率。
在ABR模式下,编码器将会按照给定的码率,尽可能为每一帧画面分配最小的量化值(量化值越小,质量越高)。
在这种模式下,因为平均码率已经指定,所以最终的文件大小是可以预计的。
Const Quantizer:恒定量化值模式。
在本模式下,编码器将会使用相同的质量去编码每一帧。
这里的质量是通过数学方法确定的(既量化值)。
在这种模式下,因为是以质量确定码率,因此最终文件大小是不可预计的,即使是质量相同的两帧,因为其复杂度不同,码率很可能相差甚远。
中文版MeGUI的x264编码配置详细解读有人向往和膜拜科班出身的,这个我同意,但若无视艹根的存在,那么我很生气,往往是民间高手如林,自己何必妄自菲薄。
一早我也说过不敢在压制的方向前进,那是因为这是个苦力不讨好的工作,有空我还不如多看看美女……只要关注,网络上的东西随处可以学习到,就对这个x264编码配置来说,网络上的资源多如脚毛。
我嫉妒恨的是科班出身的总会先天就有优势,民间人士门要蛋定,不要比,不要计较,自己玩自己的,不用理正统不正统。
我们的优势在于,科班人士再厉害他也没有拍电影也没做导演也没潜了哪个女优,嘎嘎,扯远了。
本文主要讲解x264编码的设置问题,是对应本人推荐的中文版MeGUI所做的一次详细配置论述,请用英文版的英雄路过不要取笑,也应该不要盲目的路过。
我还是传统的图文方式来一起研究,当然我说的不一定对,那是因为网络上也是这么教的,可能一直都错着我也用错的来说,在这次解释中,我会用一些自己理解的来说话,也许更能让民间人士理解。
普及一下别的知识,在各大影视论坛基本不允许发布以RMVB格式的影片,你只要用上x264的编码就意味着你和RMVB说88了。
民间人士普遍认为RMVB体积小画面清晰,但科班的人士会用理论的知识告诉你,同样的片源和同样的码率下,x264的mkv绝对比rmvb画质更好,文件更小。
这是为什么?你要问这是为什么?那是因为x264的编码机制发挥了无法想像的作用,你只要实践了就会明白这是真的,打住不说了反正就像磁带被光盘取代,windows98被xp顶上。
科班厉害之处是懂得比较多,早前的x264.exe是命令参数实现压制的,DOS级的工具很怕黑的就不要尝试了。
GUI,是图形界面操作,适合民间高手使用。
曾被科班出身的嘲笑过,说使用MeGU压制的都是水货,嘎嘎,我笑笑不能回答。
科班告诉我就这GUI不是只有Me 的,这下你明白没?像ripbot、staxrip 等都是GUI……行了行了,民间人士也不用惭愧,至少MeGUI能自动更新编码,还有汉化版可以用,batch的是高手,不和他们一起玩!安装MeGUI简体中文版(请回顾本人以前的大作,这里略去几百万字……)仿图挂,可下载中文版MeGUI的x264编码配置详细解读或是到QQ空间查阅软件下载转到论坛页面以前的中文版本MeGUI太不专业了,直到你碰到我这个民间人士才集合了比较强大的中文版MeGUI,不要怕出错,出错不是你的错。
X264参数设定详细解释x264 core:65 r1074M b6bb3d4Syntax: 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 720x480Infile 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?/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 andtextured 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 videoEach zone is of the form<start frame>,<end frame>,<option>where <option> is eitherq=<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推荐值:默认。
VFR:
VFR即Variable Frame Rate(可变帧率)的视频编码,这种VFR视频的帧率是不固定的,它可在动态画面中使用较大的帧率,而在静态画面中使用较小的帧率,这样可以有效的减少视频文件的体积,并改善动态画面的质量。
它的作用比目前广泛使用的VBR(可变码率)更为明显。
VFR有好处,也有弊端,比如不易进行各种封装操作处理等,所以VFR的视频并不多,目前主要是有部分内嵌字幕的动漫视频可能是VFR的
VFR的视频各个段落的帧率不一样,我们按照通常方式封装处理必然造成视频音频不同步,所以我们得按照它的段落排部方式来安排帧率,可通过抽取源视频timecode以便正确封装。
【翻译】x264参数介绍(⼀、帧类型和码率控制)陈钢的博客输⼊⽤1个绝对路径定义输⼊⽂件(或者2个,rawYUV⽂件)。
如下例:x264.exe -o NUL C:input.avsx264 -o /dev/null ~/input.y4m如果输⼊⽂件是rawYUV格式的,还要把分辨率⼀并输⼊。
如果开启了⽐特率控制,还需要输⼊帧率。
如下例:x264.exe -o NUL –fps 25 D:input.yuv 1280?720x264 -o /dev/null –fps 30000/1001 ~/input.yuv 640?480预设值预设值是x264在r1177版本增加的⼀个⽅便的命令⾏选项。
可以⽤x264.exe –fullhelp查看所有的命令⾏帮助。
profile默认:⽆说明:限制输出⽂件的profile。
这个参数将覆盖其它所有值,此选项能保证输出profile兼容的视频流。
如果使⽤了这个选项,将不能进⾏⽆损压缩(qp 0 or crf 0)。
可选:baseline,main,high建议:不设置。
除⾮解码环境只⽀持main或者baseline profile的解码。
preset默认:medium⼀些在压缩效率和运算时间中平衡的预设值。
如果指定了⼀个预设值,它会在其它选项⽣效前⽣效。
可选:ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow and placebo.建议:可接受的最慢的值tune默认:⽆说明:在上⼀个选项基础上进⼀步优化输⼊。
如果定义了⼀个tune值,它将在preset之后,其它选项之前⽣效。
可选:film, animation, grain, stillimage, psnr, ssim, fastdecode, zerolatency and touhou.建议:根据输⼊选择。
x264源代码解析x264编码详细文字全过程(1)x264_param_default( x264_param_t *param )作用:对编码器进行参数设定cqm:量化表相关信息csp:量化表相关信息里的memset( param->cqm_4iy, 16, 16 );memset( param->cqm_4ic, 16, 16 );memset( param->cqm_4py, 16, 16 );memset( param->cqm_4pc, 16, 16 );memset( param->cqm_8iy, 16, 64 );memset( param->cqm_8py, 16, 64 ); (2)static int Parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt ) 初始化1.getopt_long(nargc, nargv, options, long_options, idx) 得到入口地址的向量与方式的选则2.getopt_internal(nargc, nargv, options) 解析入口地址向量(3)static int Encode( x264_param_t *param, cli_opt_t *opt )/* Create a copy of param */ h->param=param/* VUI */vui信息主要包括帧率、图像尺寸等信息/* Init x264_t */x264_sps_init( h->sps, 0, &h->param );序列图像集x264_pps_init( h->pps, 0, &h->param, h->sps);图像参数集/* Init frames. */ 初始化并开辟帧空间/* init mb cache */ 对前一宏块的信息保存,因为是初始化,所以作为第一个宏块的参考,后面会有x264_macroblock_cache_load( h, i_mb_x, i_mb_y );它是将要编码的宏块的周围的宏块的值读进来, 要想得到当前块的预测值,要先知道上面,左面的预测值/* init cabac adaptive model *//* init CPU functions */ 初始化cpu对各种分块的参数设定/* rate control */1.x264_t *x264_encoder_open ( x264_param_t *param ) 这个函数是对不正确的参数进行修改,并对各结构体参数和cabac编码,预测等需要的参数进行初始化2、p_read_frame( &pic, opt->hin, i_frame + opt->i_seek, param->i_width, param->i_height )读取一帧,并把这帧设为prev3. i_file += Encode_frame( h, opt->hout, &pic );进入核心码层核心编码层的总流程图:(x264.c)1.x264_encoder_encode( h, &nal, &i_nal, pic, &pic_out )对帧进行编码2.i_size = x264_nal_encode( data, &i_data, 1, &nal[i] ) 网络打包编码3.i_file += p_write_nalu( hout, data, i_size ) 把网络包写入到输出文件中去4.返回,对下一帧进行编码下面一页是详细的流程图:一.帧内详细流程图:(1).x264_encoder_encode( h, &nal, &i_nal, pic, &pic_out )对帧进行编码1./* 1: Copy the picture to a frame and move it to a buffer */x264_frame_t*fenc=x264_frame_get( h->frames.unused );x264_frame_copy_picture( h, fenc, pic_in );fenc->i_frame = h->frames.i_input++;x264_frame_put( h->frames.next, fenc );x264_frame_init_lowres( h->param.cpu, fenc );//里面包含低象素的扩展,很多for循环,应该是抽头计算和半精度象素的扩展,要认真看(2).264_slicetype_decide( h );对slice类型的判定,里面也要看一下(3).while( IS_X264_TYPE_B( h->frames.next[bframes]->i_type ) ) bframes++;x264_frame_put(h->frames.current,x264_frame_get( &h->frames.next[bframes] ) );这主要是因为B帧必须等后面的非B帧编码结束后才能编码,所以把暂时不编的一系列B帧存入队列中,一直到非B帧才取出进行编码,之后再进行前面的B帧编码do_encode:(4).建立list0 & list1.我感觉x264_reference_build_list( h, h->fdec->i_poc, i_slice_type );比特率控制初始化x264_ratecontrol_start(h, i_slice_type, h->fenc->i_qpplus1 );(5).创建slice的头部数据x264_slice_init( h, i_nal_type, i_slice_type, i_global_qp );(6)i_frame_size = x264_slices_write( h );这是编码的关键了1. x264_slice_header_write(&h->out.bs,&h->sh,h->i_nal_ref_idc ); /* Slice header */2. 一些初始化工作3. for(mb_xy=h->sh.i_first_mb, i_skip = 0; mb_xy < h->sh.i_last_mb; mb_xy++ )对一个slice中每个宏块进行循环遍历编码,其中const int i_mb_y = mb_xy / h->sps->i_mb_width;和const int i_mb_x = mb_xy % h->sps->i_mb_width;是对宏块位置在slice中的x,y坐标的定位,这个for语句几乎覆盖了整个x264_slices_write()函数4. x264_macroblock_cache_load( h, i_mb_x, i_mb_y ); 它是将要编码的宏块的周围的宏块的值读进来, 要想得到当前块的预测值,要先知道上面,左面的预测值!5. *****x264_macroblock_analyse( h );重点。
x264命令行参数解释使用格式:x264 默认选项 -o 输出文件输入文件 [长x宽]输入支持格式:RAW/y4m/avi/avs(编译时可选)输出支持格式:264/mkv/mp4(编译时可选)x264的许多参数可以有-/--两种输入法,笔者也不知道为什么。
以下等价参数用“参数1/参数2 <必需数值格式>”表示,参数尾部()内为个人推荐。
-h/--help 帮助帧类型选项:-I/--keyint <整数> 最大IDR帧间距,默认250-i/--min-keyint <整数> 最小IDR帧间距,默认25--scenecut <整数> 画面动态变化限,当超出此值时插入I帧,默认40-b/--bframes <整数> 在IP帧之间可插入的B帧数量最大值,范围0~16,默认0--no-b-adapt 关闭自适应B帧判定(-b设为1时可用,其他不推荐)--b-bias <整数> 控制插入B帧判定,范围-100~+100,越高越容易插入B帧,默认0--b-pyramid 允许B帧做参考帧--no-cabac 关闭内容自适应二进制算术编码(CABAC,高效率的熵编码)(会提高速度,但严重影响质量)-r/--ref <整数> 最大参考帧数,范围0~16,默认1--nf 关闭环路滤波(一种除马赛克算法)-f/--filter <alpha:beta>设置环路滤波的AlphaC和Beta的参数,范围-6-6,默认都为0码率控制选项:-q/--qp <整数> 固定量化模式并设置使用的量化值,范围0~51,0为无损压缩,默认26-B/--bitrate <整数> 设置平均码率--crf <整数> 质量模式,量化值动态可变(目前不太成熟,质量不如设置固定量化值)--qpmin <整数> 设置最小量化值,范围0~51,默认10--qpmax <整数> 设置最大量化值,范围0~51,默认51--qpstep <整数> 设置相邻帧之间的量化值差,范围0~50,默认4--ratetol <小数> 平均码率模式下,瞬时码率可以偏离的倍数,范围0.1~100.0,默认1.0 --vbv-maxrate <整数> 平均码率模式下,最大瞬时码率,默认0(与-B设置相同)--vbv-bufsize <整数> 码率控制缓冲区的大小,单位kbit,默认0--vbv-init <小数> 码率控制缓冲区数据保留的最大数据量与缓冲区大小之比,范围0~1.0,默认0.9--ipratio <小数> I帧和P帧之间的量化系数,默认1.40--pbratio <小数> P帧和B帧之间的量化系数,默认1.30--色度-qp-offset <整数> 色度和亮度之间的量化差,范围-12~+12,默认0-p/--pass <1|2|3> 多次压缩码率控制1:第一次压缩,创建统计文件2:按建立的统计文件压缩并输出,不覆盖统计文件,3:按建立的统计文件压缩,优化统计文件--stats <字符串> 统计文件的名称,默认"x264_2pass.log"--rceq <字符串> 速率控制公式,默认"blurCplx^(1-qComp)"--qcomp <小数> 线性量化控制,0.0为固定码率,1.0为固定量化值,默认0.6,只用于2-pass 和质量模式--cplxblur <小数> 根据相邻帧平滑量化值比例的最大值,范围0~99.9,默认20.0,只用于2-pass和质量模式--qblur <小数> 对统计文件结果平滑量化值比例的最大值,范围0~99.9,默认0.5,只用于2-pass--zones <z0>/<z1>/…分段量化,格式为:<开始帧>,<结束帧>,<选项>,可选项为:q=<整数>(量化值)或b=<小数>(码率倍数)分析选项:-A/--analyse <字符串> 动态块划分方法,默认"p8x8,b8x8,i8x8,i4x4"。
可选项:p8x8/p4x4/b8x8/i8x8/i4x4;none/all(p4x4需要p8x8. i8x8需要--8x8dct)--direct <字符串> 动态预测方式,默认"spatial"。
可选项:none/spatial/temporal/auto-w/--weightb 允许B帧加权预测(可以减少相邻B帧质量低的影响)--me <字符串> 对全像素块动态预测搜索的方式,默认"hex",可选项:dia:菱形搜索,半径1 (快)hex:正六边形搜索,半径2umh:可变半径六边形搜索esa:全面搜索(很慢,而且效果与umh几乎相同)--merange <整数> --me为umh/esa时的搜索半径,最大64,默认16-m/--subme <整数> 动态预测和分区方式,可选项1~7,默认5(与压缩质量和时间关系密切,1是7速度的四倍以上)1:用全像素块进行动态搜索,对每个块再用快速模式进行四分之一像素块精确搜索2:用半像素块进行动态搜索,对每个块再用快速模式进行四分之一像素块精确搜索3:用半像素块进行动态搜索,对每个块再用质量模式进行四分之一像素块精确搜索4:用快速模式进行四分之一像素块精确搜索5:用质量模式进行四分之一像素块精确搜索6:进行I、P帧像素块的速率失真最优化(rdo)7:进行I、P帧运动矢量及块内部的速率失真最优化(质量最好)--b-rdo B帧也进行rdo,需要--subme在6以上--mixed-refs 可以在一帧内使用不同参考帧--no-chroma-me 不进行色度的动态预测--bime 可以平均B帧参考块的运动矢量-8/--8x8dct 可以使用8x8的离散余弦变换(DCT)-t/--trellis <整数> Trellis量化,对每个8x8的块寻找合适的量化值,需要CABAC,默认00:关闭1:只在最后编码时使用2:一直使用--no-fast-pskip 关闭快速P帧跳过检测--no-dct-decimate 关闭P帧联合编码(可以增加细节,但也会增大体积)--nr <整数> 噪声去除,范围0~100000,默认0--cqm <字符串> 设置外部量化矩阵格式,默认"flat",可选项:jvt/flat--cqmfile <字符串> 读取JM格式的外部量化矩阵文件,自动忽略其他--cqm*选项--cqm4 <list> 设置4x4的量化矩阵,用逗号分开,范围1~255的16个整数--cqm8 <list> 设置8x8的量化矩阵,用逗号分开,范围1~255的64个整数--cqm4i/--cqm4p/--cqm8i/--cqm8p 设置I、P帧不同的量化矩阵--cqm4iy/--cqm4ic/--cqm4py/--cqm4pc 设置亮度、色度不同的量化矩阵视频标准化选项:这些选项与编码无关,不过如果要用mp4之类的播放器,可以设置,风险自担--sar width:height 设置长宽比--overscan <字符串> 过扫描线,默认"undef"(不设置),可选项:show(观看)/crop(去除) --videoformat <字符串> 视频格式,默认"undef",可选项:component/pal/ntsc/secam/mac/undef--fullrange <字符串> Specify full range samples setting,默认"off",可选项:off/on(我也不明白这是干什么的,请高手指点)--colorprim <字符串> 原始色度格式,默认"undef",可选项:undef/bt709/bt470m/bt470bg,smpte170m/smpte240m/film--transfer <字符串> 转换方式,默认"undef",可选项:undef/bt709/bt470m/bt470bg/linear,log100/log316/smpte170m/smpte240m--colormatrix <字符串> 色度矩阵设置,默认"undef",undef/bt709/fcc/bt470bg,smpte170m/smpte240m/GBR/YCgCo--chromaloc <整数> 色度样本指定,范围0~5,默认0输入、输出选项:--level <字符串> 设定等级(as defined by Annex A)(不明白,请高手指点)--fps <小数> 设定帧率--seek <整数> 设定起始帧--frames <整数> 最大编码帧数-o/--output 指定输出文件--threads <整数> 编码线程(使用分片技术)--thread-input 在编码线程中运行Avisynth--no-asm 关闭全部CPU优化指令--no-psnr 关闭PSNR计算--quiet 安静模式-v/--verbose 显示每一个帧的信息--progress 显示编码进程--visualize 显示运动矢量--sps-id <整数> 设置SPS和PPS的ID值,默认0--aud 使用数据单元定义符号-----------------------------------------------------------------------------------------------------------------------------------------------2006-9-14 03:00 PM adminx264编码器参数设置详解bitrate=<value>Sets the average bitrate to be used in kbits/second (default: off). Since local bitrate may vary, this average may be inaccurate for very short videos (see ratetol). Constant bitrate can be achieved by combining this with vbv_maxrate, at significant reduction in quality.qp_constant=<0?51>This selects the quantizer to use for P-frames. I- and B-frames are offset from this value by ip_factor and pb_factor, respectively. 20?40 is a useful range (default: 26). Lower values result in better fidelity, but higher bitrates. 0 is lossless. Note that quantization in H.264 works differently from MPEG-1/2/4: H.264’s quantization parameter (QP) is on a logarithmic scale. The mapping is approximately H264QP = 12 + 6*log2(MPEGQP). For example, MPEG at QP=2 is equivalent to H.264 at QP=18.crf=<1?50>Enables constant quality mode, and selects the quality. The scale is similar to QP. Like the bitrate-based modes, this allows each frame to use a different QP based on the frame’s complexity.pass=<1?3>Enable 2 or 3-pass mode. It is recommended to always encode in 2 or 3-pass mode as it leads to a better bit distribution and improves overall quality.1first passsecond pass (of two pass encoding)3Nth pass (second and third passes of three pass encoding)Here is how it works, and how to use it:The first pass (pass=1) collects statistics on the video and writes them to a file. You might want to deactivate some CPU-hungry options, apart from the ones that are on by default.In two pass mode, the second pass (pass=2) reads the statistics file and bases ratecontrol decisions on it.In three pass mode, the second pass (pass=3, that is not a typo) does both: It first reads the statistics, then overwrites them. You can use all encoding options, except very CPU-hungry options.The third pass (pass=3) is the same as the second pass, except that it has the second pass’ statistics to work from. You can use all encoding options, including CPU-hungry ones.The first pass may use either average bitrate or constant quantizer. ABR is recommended, since it does not require guessing a quantizer. Subsequent passes are ABR, and must specify bitrate.turbo=<0?2>Fast first pass mode. During the first pass of a two or more pass encode it is possible to gain speed by disabling some options with negligible or even no impact on the final pass output quality.disabled (default)1Reduce subq, frameref and disable some inter-macroblock partition analysis modes.2Reduce subq and frameref to 1, use a diamond ME search and disable all partition analysis modes.Level 1 can increase first pass speed up to 2x with no change in the global PSNR of the final pass compared to a full quality first pass.Level 2 can increase first pass speed up to 4x with about +/- 0.05dB change in the global PSNR of the final pass compared to a full quality first pass.keyint=<value>Sets maximum interval between IDR-frames (default: 250). Larger values save bits, thus improve quality, at the cost of seeking precision. Unlike MPEG-1/2/4, H.264 does not suffer from DCT drift with large values of keyint.keyint_min=<1?keyint/2>Sets minimum interval between IDR-frames (default: 25). If scenecuts appear within this interval, they are still encoded as I-frames, but do not start a new GOP. In H.264, I-frames do not necessarily bound a closed GOP because it is allowable for a P-frame to be predicted from more frames than just the one frame before it (also see frameref). Therefore, I-frames are not necessarily seekable. IDR-frames restrict subsequent P-frames from referring to any frame prior to the IDR-frame.scenecut=<-1?100>Controls how aggressively to insert extra I-frames (default: 40). With small values of scenecut, the codec often has to force an I-frame when it would exceed keyint. Good values of scenecut may find a better location for the I-frame. Large values use more I-frames than necessary, thus wasting bits. -1 disables scene-cut detection, so I-frames are inserted only once every other keyint frames, even if a scene-cut occurs earlier. This is not recommended and wastes bitrate as scenecuts encoded as P-frames are just as big as I-frames, but do not reset the "keyint counter".frameref=<1?16>Number of previous frames used as predictors in B- and P-frames (default: 1). This is effective in anime, but in live-action material the improvements usually drop off very rapidly above 6 or so reference frames. This has no effect on decoding speed, but does increase the memory needed for decoding. Some decoders can only handle a maximum of 15 reference frames.bframes=<0?16>maximum number of consecutive B-frames between I- and P-frames (default: 0)(no)b_adaptAutomatically decides when to use B-frames and how many, up to the maximum specified above (default: on). If this option is disabled, then the maximum number of B-frames is used.b_bias=<-100?100>Controls the decision performed by b_adapt. A higher b_bias produces more B-frames (default: 0).(no)b_pyramidAllows B-frames to be used as references for predicting other frames. For example, consider 3 consecutive B-frames: I0 B1 B2 B3 P4. Without this option, B-frames follow the same pattern as MPEG-[124]. So they are coded in the order I0 P4 B1 B2 B3, and all the B-frames are predicted from I0 and P4. With this option, they are coded as I0 P4 B2 B1 B3. B2 is the same as above, but B1 is predicted from I0 and B2, and B3 is predicted from B2 and P4. This usually results in slightly improved compression, at almost no speed cost. However, this is an experimental option: it is not fully tuned and may not always help. Requires bframes >= 2. Disadvantage: increases decoding delay to 2 frames.(no)deblockUse deblocking filter (default: on). As it takes very little time compared to its quality gain, it is not recommended to disable it.deblockalpha=<-6?6>AlphaC0 parameter of deblocking filter (default: 0). This adjusts thresholds for the H.264 in-loop deblocking filter. First, this parameter adjusts the maximum amount of change that the filter is allowed to cause on any one pixel. Secondly, this parameter affects the threshold for difference across the edge being filtered. A positive value reduces blocking artifacts more, but will also smear details. The default behavior of the filter almost always achieves optimal quality, so it is best to either leave it alone, or make only small adjustments. However, if your source material already has some blocking or noise which you would like to remove, it may be a good idea to turn it up a little bit.deblockbeta=<-6?6>Beta parameter of deblocking filter (default: 0). Affects the detail threshold. Very detailed blocks are not filtered, since the smoothing caused by the filter would be more noticeable than the original blocking.(no)cabacUse CABAC (Context-Adaptive Binary Arithmetic Coding) (default: on). Slightly slows down encoding and decoding, but should save 10-15% bitrate. Unless you are looking for decoding speed, you should not disable it.qp_min=<1?51> (ABR or two pass)Minimum quantizer, 10?30 seems to be a useful range (default: 10).qp_max=<1?51> (ABR or two pass)maximum quantizer (default: 51)qp_step=<1?50> (ABR or two pass)maximum value by which the quantizer may be incremented/decremented between frames (default: 2)ratetol=<0.1?100.0> (ABR or two pass)allowed variance in average bitrate (no particular units) (default: 1.0)vbv_maxrate=<value> (ABR or two pass)maximum local bitrate, in kbits/second (default: disabled)vbv_bufsize=<value> (ABR or two pass)averaging period for vbv_maxrate, in kbits (default: none, must be specified if vbv_maxrate is enabled)vbv_init=<0.0?1.0> (ABR or two pass)initial buffer occupancy, as a fraction of vbv_bufsize (default: 0.9)ip_factor=<value>quantizer factor between I- and P-frames (default: 1.4)pb_factor=<value>quantizer factor between P- and B-frames (default: 1.3)qcomp=<0?1> (ABR or two pass)quantizer compression (default: 0.6). A lower value makes the bitrate more constant, while a higher value makes the quantization parameter more constant.cplx_blur=<0?999> (two pass only)Temporal blur of the estimated frame complexity, before curve compression (default: 20). Lower values allow the quantizer value to jump around more, higher values force it to vary more smoothly. cplx_blur ensures that each I-frame has quality comparable to the following P-frames, and ensures that alternating high and low complexity frames (e.g. low fps animation) do not waste bits on fluctuating quantizer.qblur=<0?99> (two pass only)Temporal blur of the quantization parameter, after curve compression (default: 0.5). Lower values allow the quantizer value to jump around more, higher values force it to vary more smoothly.zones=<zone0>[/<zone1>[/...]]User specified quality for specific parts (ending, credits, ...) (ABR or two pass). Each zone is <start-frame>,<end-frame>,<option> where option may beq=<0?51>quantizerb=<0.01?100.0>bitrate multiplierNOTE: The quantizer option is not strictly enforced. It affects only the planning stage of ratecontrol, and is still subject to overflow compensation and qp_min/qp_max.direct_pred=<0?3>Determines the type of motion prediction used for direct macroblocks in B-frames.None: Direct macroblocks are not used.1Spatial: Motion vectors are extrapolated from neighboring blocks. (default)2Temporal: Motion vectors are interpolated from the following P-frame.3Auto: The codec selects between spatial and temporal for each frame.Spatial and temporal are approximately the same speed and PSNR, the choice between them depends on the video content. Auto is slightly better, but slower. direct_pred=0 is both slower and lower quality.(no)weight_bUse weighted prediction in B-frames. Without this option, bidirectionally predicted macroblocks give equal weight to each reference frame. With this option, the weights are determined by the temporal position of the B-frame relative to the references. Requires bframes > 1.(no)i4x4Use additional macroblock type i4x4 (default: enabled). Without this option, P- and B-frames will use only i16x16 and the inter types specified below.(no)i8x8Use additional macroblock type i8x8 (default: enabled). This option has no effect unless 8x8dct is enabled.(no)b8x8mvUse additional macroblock types b16x8, b8x16, b8x8 (default: enabled). Without this option, B-frames will use only types i16x16, i8x8, i4x4, b16x16, skip, direct. See 4x4mv for details.(no)8x8mvUse additional macroblock types p16x8, p8x16, p8x8 (default: enabled). Without this option, P-frames will use only types i16x16, i8x8, i4x4, p16x16, skip. This option is provided for experimentation only. It is not recommended to disable 8x8mv in a real encode.(no)4x4mvUse additional macroblock types p8x4, p4x8, p4x4 (default: disabled). Without this option, P-frames will use only types i16x16, i8x8, i4x4, p16x16, p16x8, p8x16, p8x8, skip. Requires 8x8mv.The idea is to find the type and size that best describe a certain area of the picture. For example, a global pan is better represented by 16x16 blocks, while small moving objects are better represented by smaller blocks.4x4mv is recommended only with subq >= 3.(no)8x8dctAdaptive spatial transform size: allows macroblocks to choose between 4x4 and 8x8 DCT. Also allows the i8x8 macroblock type. Without this option, only 4x4 DCT is used.me=<1?4>Select fullpixel motion estimation algorithm.1diamond search, radius 1 (fast)2hexagon search, radius 2 (default)3uneven multi-hexagon search (slow)4exhaustive search (very slow, and no better than 3)me_range=<4?64>radius of exhaustive or multi-hexagon motion search (default: 16)subq=<1?7>Adjust subpel refinement quality. This parameter controls quality versus speed tradeoffs involved in the motion estimation decision process. subq=5 can compress up to 10% better than subq=1.1Runs fullpixel precision motion estimation on all candidate macroblock types. Then selects the best type. Then refines the motion of that type to fast quarterpixel precision (fastest).2Runs halfpixel precision motion estimation on all candidate macroblock types. Then selects the best type. Then refines the motion of that type to fast quarterpixel precision.3As 2, but uses a slower quarterpixel refinement.4Runs fast quarterpixel precision motion estimation on all candidate macroblock types. Then selects the best type. Then finishes the quarterpixel refinement for that type.5Runs best quality quarterpixel precision motion estimation on all candidate macroblock types, before selecting the best type (default).6Enables rate-distortion optimization of macroblock types in I- and P-frames.7Enables rate-distortion optimization of motion vectors and intra modes. (best)In the above, "all candidates" does not exactly mean all enabled types: 4x4, 4x8, 8x4 are tried only if 8x8 is better than 16x16.(no)chroma_meTakes into account chroma information during subpixel motion search (default: enabled). Requires subq>=5.(no)mixed_refsAllows each 8x8 or 16x8 motion partition to independently select a reference frame. Without this option, a whole macroblock must use the same reference. Requires frameref>1.(no)brdoEnables rate-distortion optimization of macroblock types in B-frames. Requires subq>=6.(no)bimeRefine the two motion vectors used in bidirectional macroblocks, rather than re-using vectors from the forward and backward searches. This option has no effect without B-frames.trellis=<0?2>rate-distortion optimal quantizationdisabled1enabled only for the final encode (default)2enabled during all mode decisions (slow, requires subq>=6)(no)fast_pskipPerforms early skip detection in P-frames (default: enabled). This usually improves speed at no cost, but it can sometimes produce artifacts in areas with no details, like sky.(no)dct_decimateEliminate dct blocks in P-frames containing only a small single coefficient (default: enabled). This will remove some details, so it will save bits that can be spent again on other frames, hopefully raising overall subjective quality. If you are compressing non-anime content with a high target bitrate, you may want to disable this to preserve as much detail as possible.nr=<0?100000>Noise reduction, 0 means disabled. 100?1000 is a useful range for typical content, but you may want to turn it up a bit more for very noisy content (default: 0). Given its small impact on speed, you might want to prefer to use this over filtering noise away with video filters like denoise3d or hqdn3d.chroma_qp_offset=<-12?12>Use a different quantizer for chroma as compared to luma. Useful values are in the range <-2?2> (default: 0).cqm=<flat|jvt|<filename>>Either uses a predefined custom quantization matrix or loads a JM format matrix file.flatUse the predefined flat 16 matrix (default).jvtUse the predefined JVT matrix.<filename>Use the provided JM format matrix file.NOTE: Windows CMD.EXE users may experience problems with parsing the command line if they attempt to use all the CQM lists. This is due to a command line length limitation. In this case it is recommended the lists be put into a JM format CQM file and loaded as specified above.cqm4iy=<list> (also see cqm)Custom 4x4 intra luminance matrix, given as a list of 16 comma separated values in the 1?255 range.cqm4ic=<list> (also see cqm)Custom 4x4 intra chrominance matrix, given as a list of 16 comma separated values in the 1?255 range.cqm4py=<list> (also see cqm)Custom 4x4 inter luminance matrix, given as a list of 16 comma separated values in the 1?255 range.cqm4pc=<list> (also see cqm)Custom 4x4 inter chrominance matrix, given as a list of 16 comma separated values in the 1?255 range.cqm8iy=<list> (also see cqm)Custom 8x8 intra luminance matrix, given as a list of 64 comma separated values in the 1?255 range.cqm8py=<list> (also see cqm)Custom 8x8 inter luminance matrix, given as a list of 64 comma separated values in the 1?255 range.level_idc=<10?51>Set the bitstream’s level as defined by annex A of the H.264 standard (default: 51 - Level 5.1). This is used for telling the decoder what capabilities it needs to support. Use this parameter only if you know what it means, and you have a need to set it.threads=<1?4>Split each frame into slices and encode them in parallel (default: 1). Also allows multithreaded decoding if the decoder supports it (lavc does not). This has a slight penalty to compression. Requires that libx264 was compiled with pthread support; if not, this option will produce a warning and enables slices but not multithreading.(no)globalheaderCauses SPS and PPS to appear only once, at the beginning of the bitstream (default: disabled). Some players, such as the Sony PSP, require the use of this option. The default behavior causes SPS and PPS to repeat prior to each IDR frame.log=<-1?3>Adjust the amount of logging info printed to the screen.-1nonePrint errors only.1warnings2PSNR and other analysis statistics when the encode finishes (default)3PSNR, QP, frametype, size, and other statistics for every frame(no)psnrPrint signal-to-noise ratio statistics.NOTE: The ’Y’, ’U’, ’V’, and ’Avg’ PSNR fields in the summary are not mathematically sound (they are simply the average of per-frame PSNRs). They are kept only forcomparison to the JM reference codec. For all other purposes, please use either the ’Global’ PSNR, or the per-frame PSNRs printed by log=3.(no)visualizeEnable x264 visualizations during encoding. If the x264 on your system supports it, a new window will be opened during the encoding process, in which x264 will attempt to present an overview of how each frame gets encoded. Each block type on the visualized movie will be colored as follows:red/pinkintra blockblueinter blockgreenskip blockyellowB-blockThis feature can be considered experimental and subject to change. In particular, it depends on x264 being compiled with visualizations enabled. Note that as of writing this, x264 pauses after encoding and visualizing each frame, waiting for the user to press a key, at which point the next frame will be encoded.。