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