X264設定

来自NMM Doc
Holy讨论 | 贡献2010年11月23日 (二) 17:47的版本
跳到导航 跳到搜索

本頁說明所有x264參數之目的和用法。參數的排列相同於在x264 --fullhelp出現的順序。

x264設定

說明

x264帶有一些內置的文件。要閱讀此說明,執行x264 --helpx264 --longhelpx264 --fullhelp。越後面的選項將提供更詳細的資訊。

輸入

用一個位置參數指定輸入的視頻。例如:

x264.exe -o NUL C:\input.avs
x264 -o /dev/null ~/input.y4m

當輸入的視頻是raw YUV格式時,還必須告訴x264視頻的解析度。你可能也要用--fps來指定幀率:

x264.exe -o NUL --fps 25 --input-res 1280x720 D:\input.yuv 
x264 -o /dev/null --fps 30000/1001 --input-res 640x480 ~/input.yuv

預設值系統

為減少使用者花費時間和精神在命令列上而設計的一套系統。這些設定切換了哪些選項可從x264 --fullhelp的說明中得知。

profile

預設:無

限制輸出流的profile。如果指定了profile,將覆蓋所有其他設定。所以如果指定了profile,將保證輸出的流與該profile相容。如果設了此選項,將不能使用無損編碼(--qp 0或--crf 0)。

如果知道你的播放設備僅支援某個profile,則應設此選項。大多數解碼器支援High profile,因此不需要設此選項。

可用的值:baseline, main, high

preset

預設:medium

更改選項,以權衡壓縮效率和編碼速度。如果指定了preset,更改的選項將在所有其他參數套用前被套用。

通常應將此選項設為你所能承受的最慢的值。

可用的值:ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo

tune

預設:無

調整選項,以進一步優化為視頻的內容。如果指定了tune,更改的選項將在--preset之後,但所有其他參數之前被套用。

如果視頻內容符合其中一個可用的值,則可設此選項,否則就不要指定。

可用的值:film, animation, grain, stillimage, psnr, ssim, fastdecode, zerolatency

slow-firstpass

預設:無

隨著預設值系統在r1177版本的出現,使用--pass 1會在解析命令列的最後套用以下設定:

可以設--slow-firstpass來停用此特性。使用--preset placebo也會啟用slow-firstpass。

參閱:--pass

幀類型選項

keyint

預設:250

設定x264的輸出中最大的IDR幀(亦稱關鍵幀)間隔。可以指定“infinite”讓x264永遠不要插入非scenecut的IDR幀。

IDR幀是視頻流的‘分隔符號’,所有幀都不可以從IDR幀的另一邊參考資料。因此,IDR幀也是I幀,所以它們不從任何其他幀參考資料。這意味著它們可以用作視頻的搜尋點(seek points)。

請注意,I幀通常明顯大於P/B幀(在低運動場景通常為10倍或更多),所以當它們與極低的VBV設定合併使用時會打亂碼率控制。在這些情況下,研究一下--intra-refresh

預設值對於大多數視頻沒啥問題。在為藍光、廣播、直播流或某些其他特殊情況編碼時,可能需要更小的GOP長度(通常等於幀率)。

參閱:--min-keyint, --scenecut, --intra-refresh

min-keyint

預設:自動 (MIN(--keyint/10, --fps))

設定IDR幀之間的最小長度。

對於IDR幀的說明可參閱--keyint。過小的keyint範圍可能會導致“錯誤的”IDR幀位置(例如閃屏場景)。此選項限制了在每個IDR幀之後,要有多少幀才能再有另一個IDR幀的最小長度。

min-keyint的最大允許值為--keyint/2+1。

建議: 預設值,或者等於幀率

參閱: --keyint, --scenecut

no-scenecut

預設:無

Completely disables adaptive I-frame decision.

參閱: --scenecut

scenecut

預設:40

Sets the threshold for I/IDR frame placement (read: scene change detection).

x264 calculates a metric for every frame to estimate how different it is from the previous frame. If the value is lower than scenecut, a 'scenecut' is detected. An I-frame is placed if it has been less than --min-keyint frames since the last IDR-frame, otherwise an IDR-frame is placed. Higher values of scenecut increase the number of scenecuts detected. For more information on how the scenecut comparison works, see this doom9 thread.

Setting scenecut to 0 is equivalent to setting --no-scenecut.

Recommendation: Default

參閱: --keyint, --min-keyint, --no-scenecut

intra-refresh

預設:Off

Disables IDR-frames, instead x264 uses intra coding for each macroblock in the frame every --keyint frames. Blocks are refreshed in a horizontally scrolling column - the 'refresh wave'. This benefits low-latency streaming by making it possible to achieve more constant frame sizes than is possible with standard IDR-frames. It also increases the resilience of the video stream to packet loss. This option does reduce compression efficiency, hence only use it when needed.

Fun facts:

  • The first frame is still an IDR frame.
  • Intra-blocks are placed only in P-frames - the refresh wave is wider in the first P-frame after one or more B-frames.
  • The loss in compression efficiency comes primarily from the fact macroblocks on the 'new' (left) side of the refresh wave can't refer to data on the 'old' (right) side.

bframes

預設:3

Sets the maximum number of concurrent B-frames that x264 can use.

Without B-frames, a typical x264 stream has frame types like so: IPPPPP...PI. With --bframes 2, up to two consecutive P-frames can be replaced with B-frames, like: IBPBBPBPPPB...PI.

B-frames are similar to P-frames, except they can use motion prediction from future frames as well. This can lead to significantly better efficiency in terms of compression ratio. Their average quality is controlled by --pbratio.

Fun facts:

  • x264 also occasionally distinguishes between two different sorts of B-frames. A 'B' can refer to a B-frame that is used as a reference by other frames (see --b-pyramid, while 'b' can refer to a B-frame that is not. If you see a mix of 'B' and 'b', it's usually related to the above. When the difference is not important, just 'B' is generally used to refer to all B-frames.
  • For more information about the choices x264 makes between P or B frames for each candidate frame, see this ffmpeg-devel mail. In this case, frame types will look like this (in display order) (assuming --bframes 3): IBBBPBBBPBPI.

參閱:--no-b-adapt, --b-bias, --b-pyramid, --ref, --pbratio, --partitions, --weightb

b-adapt

預設:1

Set the adaptive B-frame placement decision algorithm. This setting controls how x264 decides between placing a P- or B-frame.

0. Disabled. Pick B-frames always. This is the same as what the older no-b-adapt setting did.
1. 'Fast' algorithm, faster, speed slightly increases with higher --b-frames setting. When using this mode, you basically always want to use --bframes 16.
2. 'Optimal' algorithm, slower, speed significantly decreases with higher --b-frames setting.

Note: For a multi-pass encode, this option is only needed for the first pass where frame types are decided.

b-bias

預設:0

Controls the likelihood of B-frames being used instead of P-frames. Values greater than 0 increase the weighting towards B-frames, while values less than 0 do the opposite. This number is an arbitrary metric. The range is from -100 to 100. A value of 100/-100 does not guarantee every/no P-frame will be converted (use --b-adapt 0 for that).

Only use this if you think you make better ratecontrol decisions than x264.

參閱:--b-frames, --ipratio

b-pyramid

預設:normal

Allow the use of B-frames as references for other frames. Without this setting, frames can only reference I- or P-frames. Although I/P-frames are more valued as references because of their higher quality, B-frames can also be useful. B-frames designated as references will get a quantizer halfway between P-frames and normal B-frames. You need to use at least two B-frames before B-pyramid will work.

If you're encoding for Blu-ray, use 'none' or 'strict'.

  • none: do not allow B-frames to be used as references.
  • strict: allow one B-frame per minigop to be used as reference; enforces restrictions imposed by the Blu-ray standard.
  • normal: allow numerous B-frames per minigop to be used as references.

參閱:--bframes, --refs, --no-mixed-refs

open-gop

預設:none

Open-GOP is an encoding technique which increases efficiency. There are three modes:

  • none: Open-GOP disabled.
  • normal: Open-GOP enabled.
  • bluray: . Open-GOP enabled. A less efficient version of open-GOP, normal mode doesn't work when authoring Blu-rays.

Some decoders don't fully support open-GOP streams, which is why this hasn't been enabled by default. You should test with all decoders your streams will be played on, or (if that's impossible) wait until support is generally available.

There's an explanation of Open-GOP here.

no-cabac

預設:無

Disables CABAC (Context Adaptive Binary Arithmetic Coder) stream compression and falls back to the less efficient CAVLC (Context Adaptive Variable Length Coder) system. Significantly reduces both the compression efficiency (10-20% typically) and the decoding requirements.

ref

預設:3

Controls the size of the DPB (Decoded Picture Buffer). The range is from 0-16. In short, this value is the number of previous frames each P-frame can use as references. (B-frames can use one or two fewer, depending on if they are used as references or not.) The minimum number of refs that can be referenced is 1.

Also note that the H.264 spec limits DPB size for each level. If adhering to Level 4.1 specs, the maximum refs for 720p and 1080p video are 9 and 4 respectively. You can read more about levels and 4.1 in particular under --level.

參閱:--b-pyramid, --no-mixed-refs, --level

no-deblock

預設:無

Completely disables the loop filter. Not Recommended.

參閱: --deblock

deblock

預設:0:0

Controls the loop filter (aka inloop deblocker), which is part of the H.264 standard. It is very efficient in terms of encoding time vs. quality gained.

You can find a good description of how the loop filter parameters work in this doom9 thread (see the initial post and akupenguin's replies).

參閱: --no-deblock

slices

預設:0

Sets the number of slices per frame, and forces rectangular slices. (Overridden by either --slice-max-size or --slice-max-mbs if they are set.)

If you are encoding for Blu-ray, set this to four. Otherwise, don't use this unless you know you need to.

參閱: --slice-max-size, --slice-max-mbs.

slice-max-size

預設:0

Sets the maximum slice size in bytes, including estimated NAL overhead. (Currently is not compatible with --interlaced.)

參閱: --slices

slice-max-mbs

預設:0

Sets the maximum slice size in macroblocks. (Currently is not compatible with --interlaced.)

參閱: --slices

tff

Enable interlaced encoding and specify the top field is first. x264's interlaced encoding uses MBAFF, and is inherently less efficient than progressive encoding. For that reason, you should only encode interlaced if you intend to display the video on an interlaced display (or can't deinterlace the video before sending it to x264). Implies --pic-struct.

bff

Enable interlaced encoding and specify the bottom field is first. See --tff for more info.

constrained-intra

預設:無

Enable constrained intra prediction, which is required for the base layer of SVC encodes. Since Everyone(tm) ignores SVC you can likewise ignore this switch.

pulldown

預設:none

Signal soft telecine for your (progressive, constant framerate) input stream using one of a few preset modes. Soft telecine is explained in more detail on the HandBrake wiki. The available presets are: none, 22, 32, 64, double, triple and euro.

Specifying any mode but none implies --pic-struct.

fake-interlaced

預設:無

Mark a stream as interlaced even when not encoding as interlaced. Allows encoding of 25p and 30p Blu-ray compliant videos.