2008-11-01

x264编码参数解释

源文:http://www.digital-digest.com/articles/x264_options_page1.html


你有使用mencoder ffmpeg对视频编码成h.264吗?面对复杂的编码参数无所适从吗?读读这篇文章吧,虽然它面向StaxRip和mergui.
另外,这篇文章发布于n年前,上面所说的东西实际上已经是很老的了,如果你对新的参数有兴趣请看http://mewiki.project357.com/wiki/X264_Settings

Introduction + Basic x264 Usage

What is this guide about?
This guide aims to explain, to people just starting out with H.264 encoding, what the various options in x264 mean and how they affect the encoded video. For each option, a description is provided, as well as a list of possible options (and their descriptions), the command line version of the option and the recommend setting is shown in underline whenever possible.
If you are reading this guide, then it must mean that you already know all about H.264 and H.264 playback. If you don't, head on to our H.264 Playback Guide to get acquainted with this new video compression format.
Future versions of this guide will feature more information regarding compatibility (eg. with QuickTime, iPod, PSP, Xbox).

What is x264?
x264
x264 is a free H.264 encoder. It is mainly aimed at intermediate users, so it has lots of options that will be confusing to the average user. If you don't know your trellis from your pyramid, then this guide will hopefully help you to understand things a bit better (or just enough so that you don't have to select options at random).
The x264 options discussed in this article are ones that can be inputted using the command line version of the tool or through a Windows GUI software called StaxRip. A separate StaxRip H.264 Encoding Guide is also available, so don't fret if you can't figure out how to use this software (or to even install it).

Why use StaxRip?
Or rather, why not use MeGUI? MeGUI is probably the best tool around with dealing with x264, but it can be daunting for new users because of the numerous options that are included. StaxRip is aimed more at beginners, and so has (as the author states) only the important x264 options available to configure. Plus, StaxRip assumes no knowledge of Avisynth scripting.
You can also read our MeGUI H.264 Conversion Guide.

Software Requirements:Basic x264 usage:
At it's most basic, x264 is a command line tool, where you can specify the input, output and encoding options all through a glorious black-background/white-text command line interface.
The command line syntax is as follows

x264.exe options --output output.*** inputfile.*** widthxheight
A simple example of a x264 command line entry:
x264.exe --bitrate 1087 --output "test.mp4" "test.avi"
A more complicated example of a x264 command line entry:
x264.exe --pass 2 --bitrate 1087 --stats "test.stats" --ref 3 --bframes 3 --b-pyramid --weightb --b-rdo --bime --direct auto --filter -4:-3 --analyse all --8x8dct --subme 6 --me umh --trellis 1 --mixed-refs --progress --no-psnr --output "test.264" "test.avs"
There are many graphical user interfaces (GUIs) which allow you to set these options through a normal Windows program, and StaxRip is one of them.

Throughout this guide, whenever an x264 option is explained, both the command line equivalent and the StaxRip/GUI version of the option will be shown.

Frames Basics and x264 Profiles

Frames Basics:
Modern compressed video are made up of 3 different types of frames. Intra (I) frames (also known as key frames), Predictive (P) and Bidirectional (B) frames. Certain types of frames can be referenced, which means a frame sometimes only need to stores the difference between it-self and the referenced frame. The problem with referencing is that any error that occurs when frame Y references frame X will be carried over and propagated if frame Y is it-self referenced later on. This is why there are also frames which can't be referenced.

The I frame stores the entire image and so are the least compressible. Video seeking (when you skip to a part of a video) requires I-frames, as otherwise a symptom called seeking lag will occur when the video is blank until the next I-frame is encountered.
P-frames store the difference (called "referencing") between itself and an I-frame or other P-frames. This means P-frames can be referenced, so it needs to store enough information for this to happen, but not as much I-frames because of it's encoding technique (motion compensation).
B frames also store the differences between itself and other frames as well (uses both previous and future frames for reference), but it can't be referenced ("B-frame pyramid" excepted), so they are the most compressible (holds least amount of information). 264 supports "B-frame pyramids", which allow B-frames to be referenced for other consecutive B-frames, but otherwise B-frames can't be referenced by any other frame, so less information is stored.
So basically, a compressed video will be a combination of I, P and B frames, some referencing others. The successful combination of these frames and the referencing determines how well the video is compressed.

x264 Profiles:
Profiles are the easiest way to configure x264. Profiles are basically pre-configured x264 settings that have been saved and can be loaded time and time again to encode files. They save you time by not requiring you to re-set all the options whenever you use x264, and most importantly, they give new users a chance to experience x264 without understanding what the options are.
Sharktooth from the Doom9 forums has produced several profiles for everyday usage, and has made it available for download. You should read the official forum thread for details of what each profile is intended for, although the profiles "PD-PSP", "PD-Xbox_Hires", "PD-Xbox_LoRes" and "PD-iPod" should come in handy for encoding a PSP/Xbox/iPod compatible video. There are even profiles specifically designed for Anime/cartoons
The other piece of good news is that software like MeGUI allow you to import profiles, and StaxRip has these profiles built into the software it self (and also allow you to edit and create your own profiles).
But what if you are curious and you want to find out just what options are being selected in a profile? It's actually very easy to view profiles, because they are actually just XML files. Clicking on the XML file should open them in Internet Explorer, and you should see a screen similar to the one below:
Profiles

What the above shows is that for this particular profile, NbBframes to 3, KeyframeInterval to 250, trellis to false and so on. On the x264 command line, the three options I've mentioned would translates to the following:
x264.exe --bframes 3 --keyint 250 --trellis 0








导言和与x264的基本用法

本篇指导的内容


  这篇指导文章的目的是向那些刚开始了解H.264编码的人们解释这些纷繁复杂的选项的意义以及它们对编码的视频的影响。每个选项我都将提供它的描述,以及一个相关选项的列表,命令行选项和推荐参数设置尽可能添加下划线。

  我假设正在阅读这篇文章的你已经了解了H.264和H.264回放,如果你不清楚的话,清先阅读我们的H.264回放指导以便于了解这种新的压缩格式。

  这篇指导的新版本将添加更多的关于兼容性的信息(比如QuickTime,iPod,PSP,Xbox)




什么是x264?

  x264是一个免费的H.264编码器,它主要中级用户,所以它拥有的大量的选项将会让普通用户头痛死。如果你不了解你的水平,那么这篇文章可能帮助你增加一些了解(即便是能够让你不至于乱用选项)

  这篇文章中讨论的x264选项是那些能够在命令行版本编码器中输入的,或者通过一个windows下的被成为StaxRip的图形程序使用的。你也可以阅读StaxRip H.264 Encoding Guide。所以如果你不懂如何使用那个软件也不必烦恼。




为什么使用StaxRip?

  或者更进一步问,为什么不实用MeGUI?它也许是处理x264最好的工具,但是对新手来说它那大量的选项太复杂了,而这款软件是面向初学者的,并且允许导入x264选项处理,此外,它还不需要Avisynth脚本的知识。
你也可以阅读我们的MeGUI H.264 Conversion Guide.



软件需求:

基本的x264用法:

  这是最基本的用法,x264是一个命令行工具,你能指定输入,输出文件,和编码选项通过这个黑白的命令行交互窗口。

  命令行的使用语法是这样的:

x264.exe options --output output.*** inputfile.*** widthxheight

一个通过命令行使用x264的例子:

x264.exe --bitrate 1087 --output "test.mp4" "test.avi"

一个更加复杂的命令行使用x264的例子:

x264.exe --pass 2 --bitrate 1087 --stats "test.stats" --ref 3 --bframes 3 --b-pyramid --weightb --b-rdo --bime --direct auto --filter -4:-3 --analyse all --8x8dct --subme 6 --me umh --trellis 1 --mixed-refs --progress --no-psnr --output "test.264" "test.avs"


  有很多普通的windows下的图形用户界面程序允许你设置这些参数。StaxRip就是其中之一。

  通过这篇指导,你将了解所有的x264可选参数,包括命令行和软件版本的选项.




帧基础和x264 profiles
帧基础

  现代压缩视频是由三种不同的帧组成: Intra (I) frames(内部帧(非官方翻译),也被称作关键帧),Predictive (P)(预测帧(非官方翻译)) 和 Bidirectional (B) frames(双向帧(非官方翻译)).每个类型的帧将会被引用,这意味着一个帧有时候只需要保存它自己和被它引用的帧的不同之处。引用导致的问题是,假设当Y帧引用X帧的时候,如果Y帧之后被引用的话,发生的错误将被一直传递。这就是为什么有一些帧是不能被引用的原因。

  I帧存储着整个图像,所以它最不能被压缩,视频查找(当你跳过一个部分视频的时候)就需要I帧,否则当视频是空的时候并且未遇到下一个I帧时,就会发生查找滞后的现象。

  P帧存储着它与I帧和其他P帧的不同之处(被称作引用),这意味着P帧能被引用, 所以它需要存储有足够的信息以保证引用的正确,但是由于编码技术的运动补偿,它并不需要存有I帧那么多的信息。

  B帧也保存着它与其他帧的不同之处(通过同时使用先前的数据以及引用它的帧的数据),但是它不能被引用(B-frame pyramid例外),所以他们是最能被压缩的部分(因为他们只需要保有最少的信息),264支持所谓的 "B-frame pyramids",这项技术允许B帧被其他连续的B帧引用,除此之外B帧不能被其他任何B帧引用。因此保证了它可以保存最少的信息。

  所以,基本上一个压缩过的视频将包含I,P和B帧,其中一些引用另外一些。一个视频压缩的好不好取决于是否能够成功的混合这些帧和处理好其中的引用关系。




x264 Profiles:

  Profiles是最简单的配置x264的方法,Profiles是已存档的基本的x264预配置文件,它能够随时被读取来编码视频。他们能够让你不需要每次都被重复要求设置所有选项,从而大大的节省了你的时间。并且,最重要的是,他们可以让一个新手有机会体验x264而不需要去了解那些选项是干什么的。
Doom9论坛的Sharktooth制作了许多profiles文件以供日常使用。你可以下载它,你应该阅读论坛的官方帖子以了解每个profiles文件的详细情况与用处,尽管那些profiles文件比如"PD-PSP", "PD-Xbox_Hires", "PD-Xbox_LoRes" 和"PD-iPod"可以让我们很便捷的编码出适用于PSP/Xbox/iPod的视频,不过我们还能找到专为动画设计的profiles文件哦。

  另外一个好消息是像MeGUI这样的软件允许你导入profiles,而StaxRip则内建了一个profiles文件,同样它也允许你编辑和创建自己信的profiles文件。
  不过,要是你是个很有好奇心的人,并且你想要去找出每个选项的用处,你可以很容易的查看profiles文件,因为它们是标准的xml文档,在ie中打开它你会看到下面的内容:



Profiles

  上面这个profiles配置了NbBframes为3,KeyframeInterval为250,trellis被禁用等。用命令行来表示就会被翻译成:



x264.exe --bframes 3 --keyint 250 --trellis 0




x264 Options: Common

x264 Options: Common


Mode:

Description: Selects the encoding mode to be used by the encoder. Single pass encoding can give unexpected output file sizes (Quantizer and Quality modes) and/or poorer quality compared to multi pass encoding.
Available Options:
Single Pass - Bitrate: Encodes the video once (single pass) with a set constant bitrate for each frame
Single Pass - Quantizer: Single pass encoding with a set quantizer (higher quantizer => lower quality) for each frame
Single Pass - Quality: Single pass encoding with a set quality rating for each frame
Two Pass: Encodes the video twice (once to determine it's properties, another to ensure the selected output file size is reached with maximum efficiency). This is the most common setting.
Three Pass: Same as Two Pass except for an extra encoding pass to ensure even better quality/accurate file size
Command Line: --bitrate, --qp, --crf, --pass 1/2/3

Quantizer:

Description: Only available with "Single Pass - Quantizer" mode is selected. Set the quantizer value for the encoding. A high quantizer will equal a low quality (and smaller file size). A quantizer value between 20 (high quality) and 30 (low quality) should be used. Anime/cartoons or scenes with large patches of color or less details benefit from having a higher quantizer, typical movies require a lower quantizer.
Command Line: --qp n
(where 'n' is the quantizer value)

Quality:

Description: Only available with "Single Pass - Quality" mode is selected. Set the quality value for the encoding. A high quality value equals a higher quality encoding (and larger file size).
Command Line: --crf n
(where 'n' is the quality value)

B-Frames:

Description: Selects the number of consecutive B-frames x264 should use. It is also the maximum number of consecutive B-frames x264 can use if the "Adaptive" B-frames option (see next section) is selected. B-frames are frames that are small in size, but when placed correctly, offer no loss of quality. This can help improve compression. With the "Adaptive" option on (x264 will decide how many B-frames to use), having a setting of 3 is recommended as this gives x264 enough room to work with.
Command Line: --bframes n
(where 'n' is the number of B-frames)

Reference Frames:

Description: Selects the maximum number of reference frames that can be used. Referenced frames are frames that refer to other frames (eg. if both frames are similar). Having a high referenced frame will improve quality but slow up encoding. For typical content, a reference frame of 3 to 5 is recommended. For content with a lot of repetition (eg. animation), a reference frame of 8 to 10 can be used. If a large number of reference frames is selected, then the "Mixed References" options should also be selected to allow x264 greater control (see "Analysis Options" section).
Command Line: --ref n
(where 'n' is the number of reference frames)

Loop Filter:

Description: Also known as "de-blocking" filter. Connected with the "Alpha" and "Beta" setting next to it. One of the fundamental differences between H.264 and previous codecs. Should always be enabled or excessive video artifacts may appear. Controversial because blocking (when the video looks like a series of different colored squares in low bitrate video) and artifacts are treated as details by the human visual system, and removing them makes people think details is lost, when it's actually the other way around (more "actual" details shown due to less artifacts). This is an interesting topic that is better discussed in DeathTheSheep's x264 guide.
Command Line: --nf
(disables loop filter)

Alpha/Beta:

Description: This controls the "Loop Filter" (see above). Also known as Strength (Alpha) and Threshold (Beta). Alpha determines the strength of the deblocking action. Beta determines when x264 decides something is a block and when something isn't - a high value means x264 sees more video as blocks than a lower value. For example, a too high Beta value and a too high Alpha means x264 will identify too many blocks (even when they aren't artifacts) and apply too much filtering to remove them, making the picture look "washed out" and lacking detail. Both values can be positive or negative. 0/0 (Alpha/Beta) is the default and recommended setting, unless you find the video quality unacceptable, then you should try combinations. Do not go under -2 or above 3. This is an interesting topic that is better discussed in DeathTheSheep's x264 guide.
Command Line: --filter

x264 选项: 普通部分

x264 Options: Common


模式:

说明选择编码器使用的编码模式,一次编码输出的文件可能不能断定大小(在量化器和质量模式下)并且/或者可能会产生比二轮编码烂一点的质量。


可用选项

Single Pass -Bitrate:用对每帧固定码率的设置一次编码视频。

Single Pass -Quantizer:用一个对每帧设置量化器的设置一次编码视频。

Single Pass -Quality:用一个对每帧设置与源文件的质量比率的设置来一次编码视频。

Two Pass:两次编码视频,第一次检测视频文件的信息,蝶如此确保输出的视频在确定的码率下质量最大化。这是最常用的设置。

Three Pass:同二次编码垒石,只是多用了一轮编码来确保更佳的文件品质。

命令行:-bitrate, -qp ,-crf ,-pass 1/2/3


量化器:


说明只有当使用“一次编码量化器模式”的时候可用,需要设置量化器的值,值越高,表示越低的质量越小的文件。可以使用20-30之间的值。动画和卡通或者是一个有着大块相同色彩的区域的场景以及一个比较少细节的画面可以设置一个比较好的量化器值,普通的电影用比较少的值



命令行: -qp n (n为量化器的值)






质量:

说明: 只在“一次编码质量模式“被选用的模式下可用,这是一个值作为编码的质量,越高的值代表越高的质量,越大的文件,




命令行: --crf n (n为质量的值)


B帧:

说明: 选择x264使用的连续b帧的数量,这也是当Adaptive B帧选项被使用时x264可用的b帧的最大数量,b帧虽然体积小,但是当插入的位置正确的话不会降低质量。因此能够提升压缩率。当采用了Adaptive 选项的时候推荐把这个值设置为3以便于给x264程序足够的空间处理。








命令行: --bframes n (n表示b帧的帧数)

引用帧:


说明: 选择引用帧的最大可用值,引用帧引用了其他的帧(比如当两个帧非常相似时),引用帧多的话会提升质量,但是会减慢编码速度。对于一般的视频内容,设置它为 3到5是一个比较不错的选择,对于有着大量重复内容的视频来说(比如动画)可以把它设置为8到10,如果使用了大量的引用帧,那么应该使用Mixed References选项,以便于允许x265更好的控制编码






Command Line: --ref n (n表示引用帧的帧数)


循环过滤:

说明:也 被称作“去块效应滤镜”,需要紧跟着Alpha和Beta设置,H.264同之前的编码器的一个根本性的区别就是它总是允许过度的artifacts存 在,这样的处理有很大的争议,由于块效应(当视频在地码率下看起来像一系列不同的色块堆积而成的)和artifacts被人的视觉系统作为画面细节对待, 移除它们会让人觉得视觉细节丢失了,虽然实际的效果正好相反(越少artifacts会让人觉得有越多的“实际”细节),这是一个有趣的讨论题目,在这篇 文章中有详细的讨论:DeathTheSheep's x264 guide.





命令行: --nf (禁用循环过滤)

Alpha/Beta:

说明:这 个选项控制循环过滤。Alpha也作为Strength,Beta也作为Threshold,alpha决定去块效应的强度,beta控制x264判定某 物是否是块。越高的值意味着x264把越多的东西作为块,例如,一个很高的beta值和一个很高的alpha值将判定过多的块(即使它们并非 artifacts)并且将允许更多此过滤来除去它们,这以为着图像会丢失很多细节。这两个值都可以是正负的。推荐把它们都设置为0,除非你发现视频的质 量实在让人无法接受。否则不要调整,而且即使调整也不要低于-2或高于3。



命令行: --filter

x264 Options: B-Frames


x264 Options: B-Frames


Direct Mode:
Description: This option when selected can improve compression efficiency. Disabled by default, Auto seems to be the most common value, with Spatial being used occasionally.
Available Options:
None
Spatial
Temporal: least used (at least in Sharktooth's profiles)
Auto: most common
Command Line: --direct x
(where 'x' is 'none', 'spatial', 'temporal' or 'auto')

Bias:
Description: Sets how much bias x264 should give the usage of B-frames (higher means more use of B-frames). Setting this to 100 is the equivalent of not selecting the "Adaptive" option (see below). A default value of 0 works well. Option only available when at least 1 B-frame has been set.
Command Line: --b-bias n
(where 'n' is the bias value)

Adaptive:
Description: Turns on adaptive B-frames, which allows x264 to determine the number of B-frames to use (within the set B-frames limit in the previous section). A default value of On works well. Option only available when at least 1 B-frame has been set.
Command Line: --no-b-adapt
(disables adaptive B-frames)

Pyramid:
Description: Turns on B-frame Pyramid option, which allows B-frames to be used as references for other B-frames in prediction. A default value of On (when available) works well. Option only available when at least 2 B-frame has been set.
Command Line: --b-pyramid
(enables adaptive B-frames)

RDO:
Description: Turns on/off RDO for B-Frames. Turning it On will improve quality at the expense of encoding speed, but it is almost always worth it. Must have at least 1 B-frame and must have a "Subpixel Motion Estimation" (see "Analysis options" section) of 6 or 7.
Command Line: --b-rdo
(enables RD based mode decision for B-frames)

Weighted Prediction:
Description: Turns on weighted prediction for B-frames, which results in improved accuracy and therefore a more efficient encoding. Set it to On in most cases. Option only available when at least 1 B-frame has been set.
Command Line: --weightb
(enables weighted prediction)

Bidirectional M.E.:
Description: Turns on bidirectional M.E, which allows predictions based on motion both before and after the B-frames. Set it to On in most cases.
Command Line: --bime
(enables bidirectional M.E.

x264选项: B帧部分


x264 Options: B-Frames


直接模式:

说明:这个选项可以提升压缩性价比,默认禁用,自动是最常用的选择,偶尔会用到Spatial

可用选项:

None
Spatial
Temporal: 极少使用
Auto: 最常用

命令行: --direct x ('x' 可以是 'none', 'spatial', 'temporal' 或 'auto')

Bias:

说明: 设置x264使用多少斜线,越高的值使用越多的b帧,设置这个为100等价于不使用Adaptive选项,默认值是0,这个值能很好的工作,要设置这个选项要求b-frames大于1




命令行: --b-bias n (n为bias的值)

Adaptive:

说明: 打开B帧的自适应,将允许x264决定使用b帧的数量(在bias中设置的值会限制这个数量),默认值是开启,只有当B-frame设置大于1的时候有效


命令行: --no-b-adapt (禁用 adaptive B-frames)

Pyramid:

说明: 打开b帧金字塔层次选项, 将允许b帧引用其他b帧来预测,默认打开(当可用时),只有当B-frame设置大于2的时候有效


命令行: --b-pyramid (打开b pyramid)

RDO:
说明:为b帧打开或者关闭RDO,开启这个选项能提升质量而仅仅减少一点编码速度,这个代价通常是值得的,b-frame必须大于1并且必须有“子像素运动估计”




命令行: --b-rdo (开启b帧的rd基础判断模式)

权重预测:


说明: 打开b帧的权重预测,这将提升精确度,即使编码更具性价比,大多数情况下都开启这个,只有当B-frame设置大于1的时候有效


命令行: --weightb (开启权重预测)

双向M.E.:


说明: 打开双向M.E,这将允许基于这个b帧的前后帧的变化来预测,多数情况都打开它


命令行: --bime (打开双向M.E)

x264 Options: Frame Options

x264 Options: Frame Options


Scene Cut:

Description: This option sets how x264 determines when a scene change has occurred and hence when a key frame is needed. A higher value will allow x264 to be more sensitive to scene changes. A video that has very few camera movements may require a higher scene cut value, for example. The default value of 40 should work well in most cases, plus or minus 5 for low/high action videos.
Command Line: --scenecut n
(where 'n' is the scene cut value)

CABAC:

Description: Stands for Context Adaptive Binary Arithmetic Coding. Improves encoding efficiency at the expense of playback/decoding efficiency. The default option of leaving this setting On is recommended, unless the encoded video is to be played back on devices with limited decoding power (eg. portable devices such as the iPod or high resolution clip playback on the Xbox).
Command Line: --no-cabac
(disables CABAC)

GOP Size (Min/Max):

Description: This option sets the minimum and maximum number of frames before a key frame has to be inserted by x264. For example, a minimum setting that is the same as the framerate of the video (eg. 24/25/30) will prevent the encoded video from having two subsequent key frames within a second of each other, which only aims to increase file size without any noticeable quality improvements.

Similarly, a maximum setting ensures that a key frame is inserted at least every X number of frames. A video without key frames will have lower quality and there will be problem with seeking (if you try to skip to a part of the video without a key frame, there won't be any video until the next key frame is reached, also known as "seeking lag"). A recommend setting, as with DivX/XviD encoding, is to set this as 10 times the framerate, which equates to 10 seconds of video between key frames (ensures "seeking lag" is at most 10 seconds).
Command Line: --keyint m --min-keyint n
(where 'm' and 'n' are the max and min GOP size values)



x264 Options: Analysis

x264 Options: Analysis


Mixed References:

Description: This option allows x264 to have greater control over "Reference Frames" (see "Common options" section). Especially needed if the "Reference Frames" is set to a high value.
Command Line: --mixed-refs
(enables mixed references)

No Fast P Skip:

Description: Fast P Skip can improve encoding speed at the expense of a very slight quality drop. Leave this option set to Off (to allow for Fast P Skips) is recommended unless encoding for maximum quality with no regard to encoding time.
Command Line: --no-fast-pskip
(disables fast P skip)

Motion Estimation Method:

Description: This option select the way motion is detected by x264. Motion is what compression codecs are all about, tracking differences between scenes to allocate the various frame types and bitrates.
Available Options (listed from fastest to slowest, encoding speed wise):
Diamond: Only use when maximum encoding speed is required.
Hexagon: A good option for when quality is not the most important factor, but still important.
Multi Hex: Also known as "Uneven Multi-Hexagon". This is the most common setting, as it is a good trade off between speed and quality.
Exhaustive: Slowest and totally unnecessary (it isn't estimation anymore, rather, it's Motion Calculation, pixel by pixel).
Command Line: --me x
(where 'x' is 'dia', 'hex', 'umh' or 'esa')

Subpixel Motion Estimation:

Description: Also known as "Partition Decision". A very important option that determines how x264 makes decisions about motion estimation. The options are available from 1 to 7, with 1 being the fastest (lowest quality) and 7 being the slowest (best quality). A setting of 6 is the most common, with 1 or 7 being used in extreme cases (fastest encoding or best quality). A setting of 6 or 7 enables the B-frames RDO option (see "B-Frames options" section).
Command Line: --subme n
(where 'n' is the estimation value)

Trellis RD Quantization:

Description: This option when turned on is supposed to improve quality, but at a severe slow down of encoding. The quality improvements are also subjective. Leaving it Off is recommended unless you have a fast computer and using multi-pass encoding. Never turn it on in single pass quantizer mode, as it would lead to unexpected results.
Available Options:
Disabled: Use this for 1-pass encoding
Final MB: Use this for typical 2-pass encoding
Always: Use this for maximum quality (slowest speed)
Command Line: --trellis n
(where 'n' is 0 {disabled}, 1 {Final MB} or 2 {Always})

x264选项:帧选项部分:

x264 Options: Frame Options

Scene Cut:

说明: 这个选项决定x264如何判断当场景发生改变的时候是否需要插入关键帧,一个高的值将允许x264对场景变化更加敏感,如果一个视频只有很少的摄像机移动的话就需要更高的值,例如,默认的值40将在绝大多数情况下工作的很好,一般我们只在这个值上增删5左右。




命令行: --scenecut n

CABAC:

说明:CABAC表示上下文适应的二进制算术编码。这个选项能够提高编码效率,而只会略微将少编码和解码的效率,默认选项就是打开,我们推荐打开,除非视频回放设备很烂。








命令行: --no-cabac (禁用 CABAC)

GOP 大小 (Min/Max):

说明:这个选项设置了x264在每个关键帧前面插入的最大和最小帧数,例如,把最小值设置成和视频帧率一致(比如24/25/30)将防止编码的视频一秒之内有两个连续的关键帧(这种情况只会增加视频的大小却不能增加其质量)。

   类似的,最大值确保关键帧至少在每x个帧中能被插入,一个没有关键帧的视频的质量很低而且有寻址问题,(如果你试着去跳过包含关键帧的视频的一部分,那 么你就会直接跳到下一个关键帧处)。推荐的设置和DivX/XviD编码一样,把它设置为帧率的10倍,也就是每十秒一定有一个关键帧(这样确保寻址延迟 最多十秒)




命令行: --keyint m --min-keyint n ( 'm' 和 'n' 分别代表max和min)



x264选项:


x264 Options: Analysis


混合:

说明:这个选项允许x264对引用帧有更好的控制,尤其是当引用帧设置到很高的值的时候更加需要这个参数


命令行: --mixed-refs (开启混合引用)

禁用快速跳过p帧:

说明: 快速跳过p帧能够提升编码速度,而仅仅轻微降低视频质量,把这个选项设置为off能开启快速跳过p帧,我们推荐这样做,除非你更在意编码速度,而不是质量



命令行: --no-fast-pskip (禁用快速跳过p帧)

运动估计方式:


说明: 这个选项设定x264检测运动的方式,运动是视频编码的全部,追踪两个场景中的不同之处,并且分配帧类型和比特率
可用选项(从编码速度最快的排到最慢的):
Diamond:只有当要求最快的编码速度时使用。。
Hexagon:当视频质量不是最重要,但也是一个重要参考因素的时候使用。
Mulit Hex:也被称作“非匀称六边形搜索“这个是最常用的选项。它能够很好的平衡质量与速度,
Exhaustive:最慢的并且完全不必要的选项。它搜索所有像素。







命令行: --me x ( 'x' 可以是 'dia', 'hex', 'umh' 或 'esa')


子像素运动估计:


说明: 也被成为分区判断,一个非常重要的选项,以决定x264怎样判断运动估计。值可以从1到7,1是最快但最低质量的方式,7是最慢当最高质量的方式,一般设置为6,1和7一般只有在极端条件下使用。设置为6或7允许B帧RDO选项





命令行: --subme n (n为评估值)

RD栅格量化:


说明: 开启这个选项可以提升质量,但是会严重降低编码速度,而且质量提升也是主观的,一般推荐关闭,除非你有一台高速计算机并且使用多次编码,不论如何,绝对不要在一次量化器编码模式下使用它,否则会造成不可预期的结果。



可用选项:
Disabled: 只用一次编码的时候使用
Final MB: 一般多次编码的时候用这个
Always: 最大质量模式,也最慢



命令行: --trellis n
( 'n'为 0 代表{disabled}, 1 代表{Final MB} 或 2 代表{Always})

x264 Options: Partitions


x264 Options: Partitions


Partitions:
Description: These options determine the partition search types. Generally, you want to enable all of these options whenever possible, as they will improve encoding quality. The "P4x4" option requires the "P8x8" option.
Command Line: --analyse x
(where 'x' is 'p8x8', 'p4x4' {requires 'p8x8'}, 'b8x8', 'i8x8', 'i4x4' , 'none' or 'all')

8x8 DCT:
Description: This option has been separated from the above because it has a different command line flag. This option is required if you want to select the "I8x8" option above.
Command Line: --8x8dct
(enables 8x8 DCT)


x264 Options: Input/Output


Show progress indicator:

Description: This option when enabled shows you how many frames have been encoded and how many frames are left. Best to leave it On if you don't want to sit there guessing how much is still left to do.
Command Line: --progress
(enables progress indicator)



Disable PSNR computation:

Description: This option disables noise reduction calculations. It is recommended that you leave this option On (to diable PSNR).
Command Line: --no-psnr
(disables PSNR computation)



Threads:

Description: This sets the number of CPU threads to use in encoding. An Intel Pentium processor with HyperThreading counts as 2 threads. Dual Core processors are also 2 threads. Dual core processor with HyperThreading (eg. Intel Extreme Edition) will have 4 threads.
Command Line: --threads n
(where 'n' is the number of threads)



Output Type:

Description: Selectable within the x264 command line by the output filename. A file with extension .264 will equal the "RAW" setting.
Command Line: --output x
(where 'x' is the output filename with the extension being .264, .mp4 or .mkv to indicate output type)

x264选项: 分区


x264 Options: Partitions


分区:
说明: 这个选项决定分区搜索方式,你会希望把它设置为all,这样能提升编码质量,P4x4选项要求开启p8x8, p4x4只在subq >= 5,并且分辨率低时才推荐使用。



命令行: --analyse x ( 'x' 是 'p8x8', 'p4x4' {需要 'p8x8'}, 'b8x8', 'i8x8', 'i4x4' , 'none' 或 'all')

8x8 DCT:

说明: 这个选项被从上面单独分离出来是因为它的命令标志不同于上面的,这个选项要求你开启i8x8

命令行: --8x8dct (开启 8x8 DCT)



x264 Options: Input/Output


禁用PSNR 计算:

说明: 这个选项禁用降噪运算,推荐开启它以禁用降噪运算




命令行: --no-psnr (禁用 PSNR 运算)



Threads:

说明: 这个选项设置cpu编码线程数。支持intel的HT技术的cpu每个核心被视为2个线程,双核处理器也是2个线程,双核ht的cpu就是4线程了。
命令行: --threads n
( 'n'表示线程数)

没有评论: