arm-linux-gcc編譯x264

arm-linux-gcc編譯x264
來源: ChinaUnix博客  日期: 2008.12.17 11:30 (共有條評論) 我要評論
 
要做視頻傳輸,時間又緊迫,本人的“家底”又特別薄,就在網上下了個x264編碼的,在Linux下能編譯過去的。首先得配置一下:./configure  --disable-asm,之後找到它默認的編譯工具,然後修改它。在配置文件裏,用vi打開它,找到 CC="${CC-gcc}" 這就是在configure文件裏的定義,所以默認的是用gcc編譯器編譯的,若想修改編譯器,把它修改了就行,若想用arm-linux-gcc編譯,就可以修改爲:CC="${CC-arm-linux-gcc}",然後make一下,就可以啦,這樣就生成了x264的可執行文件和libx264.a庫文件。記住,要想修改編譯器,記着在這些配置文件查看默認的編譯器的定義所在,然後修改它。這只是看能否用交叉編譯工具能否編譯過去,用同樣的方法可以在x86的機器上編譯,當然編譯器得改回來。之後就可以在網上下載一個 .yuv的測試文件,可以在
http://www.cipr.rpi.edu/resource/sequences/sif.html
上面下載,那裏有很多。對於 x264的參數可以用 ./x264 --help 就可以查看出其用法:如下

Syntax: x264 [options] -o outfile infile [widthxheight]
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 (no).
Outfile type is selected by filename:
.264 -> Raw bytestream
.mkv -> Matroska
.mp4 -> MP4 if compiled with GPAC support (no)
Options:
  -h, --help                  List the more commonly used options
      --longhelp              List all options
Frame-type options:
  -I, --keyint       Maximum GOP size [250]
  -b, --bframes      Number of B-frames between I and P [0]
      --b-pyramid             Keep some B-frames as references
      --no-cabac              Disable CABAC
  -r, --ref          Number of reference frames [1]
  -f, --deblock   Loop filter AlphaC0 and Beta parameters [0:0]
      --interlaced            Enable pure-interlaced mode
Ratecontrol:
  -q, --qp           Set QP (0=lossless) [26]
  -B, --bitrate      Set bitrate (kbit/s)
      --crf            Quality-based VBR (nominal QP)
      --vbv-bufsize  Enable CBR and set size of the VBV buffer (kbit) [0]
      --ratetol        Allowed variance of average bitrate [1.0]
      --ipratio        QP factor between I and P [1.40]
      --pbratio        QP factor between P and B [1.30]
      --aq-mode      How AQ distributes bits [2]
                                  - 0: Disabled
                                  - 1: Avoid moving bits between frames
                                  - 2: Move bits between frames
      --aq-strength    Reduces blocking and blurring in flat and
                              textured areas. [1.0]
                                  - 0.5: weak AQ
                                  - 1.5: strong AQ
  -p, --pass           Enable multipass ratecontrol
                                  - 1: First pass, creates stats file
                                  - 2: Last pass, does not overwrite stats file
                                  - 3: Nth pass, overwrites stats file
      --stats         Filename for 2 pass stats ["x264_2pass.log"]
      --qcomp          QP curve compression: 0.0 => CBR, 1.0 => CQP [0.60]
      --zones //...  Tweak the bitrate of some regions of the video
Analysis:
  -A, --partitions    Partitions to consider ["p8x8,b8x8,i8x8,i4x4"]
                                  - p8x8, p4x4, b8x8, i8x8, i4x4
                                  - none, all
                                  (p4x4 requires p8x8. i8x8 requires --8x8dct.)
      --direct        Direct MV prediction mode ["spatial"]
                                  - none, spatial, temporal, auto
  -w, --weightb               Weighted prediction for B-frames
      --me            Integer pixel motion estimation method ["hex"]
                                  - dia, hex, umh
      --merange      Maximum motion vector search range [16]
  -m, --subme        Subpixel motion estimation and partition
                                  decision quality: 1=fast, 7=best. [5]
      --b-rdo                 RD based mode decision for B-frames. Requires subme 6.
      --mixed-refs            Decide references on a per partition basis
  -8, --8x8dct                Adaptive spatial transform size
  -t, --trellis      Trellis RD quantization. Requires CABAC. [0]
                                  - 0: disabled
                                  - 1: enabled only on the final encode of a MB
                                  - 2: enabled on all mode decisions
      --no-fast-pskip         Disables early SKIP detection on P-frames
      --no-dct-decimate       Disables coefficient thresholding on P-frames
      --nr           Noise reduction [0]
      --cqmfile       Read custom quant matrices from a JM-compatible file
Input/Output:
  -o, --output                Specify output file
      --sar width:height      Specify Sample Aspect Ratio
      --fps   Specify framerate
      --seek         First frame to encode
      --frames       Maximum number of frames to encode
      --level         Specify level (as defined by Annex A)
  -v, --verbose               Print stats for each frame
      --progress              Show a progress indicator while encoding
      --quiet                 Quiet Mode
      --no-psnr               Disable PSNR computation
      --no-ssim               Disable SSIM computation
      --threads      Parallel encoding
      --thread-input          Run Avisynth in its own thread
其中文說明網上也有很多,下面摘自
http://popgo.net/bbs/showthread.php?s=f216651231abb8900e082602196a6150&threadid=408981
對其參數的說明:
x264參數解釋(revision: 1024)
本文對應的是x264命令行模式,VFW方式也用相同的參數,不過是圖形界面,可以自己找對應的英文。
新版本x264取消了--no-b-adapt、--nf、--b-rdo、--bime、--rceq參數,請不要再使用。
使用格式:x264 默認選項 -o 輸出文件 輸入文件 [長x寬]
輸入支持格式:RAW/y4m/avi/avs(編譯時可選)
輸出支持格式:264/mkv/mp4(編譯時可選)
x264的許多參數可以有-/--兩種輸入法。以下等價參數用“參數1/參數2 ”表示。
-h/--help 列出較常用的選項
--longhelp 列出較常用的選項,更詳細的幫助
幀類型選項:
-I/--keyint  最大IDR幀間距,默認250
-i/--min-keyint  最小IDR幀間距,默認25
--scenecut  畫面動態變化限,當超出此值時插入I幀,默認40
--pre-scenecut         更快,但低精度的畫面動態檢測,需要多線程,並且在啓用多線程時自動打開。
-b/--bframes      在IP幀之間可插入的B幀數量最大值,範圍0~16,默認0
-b-adapt 自適應B幀判定模式。 0:關閉;1:快速;2:優化(高B幀時速度大大下降),默認1
--b-bias  控制插入B幀判定,範圍-100~+100,越高越容易插入B幀,默認0
--b-pyramid             允許B幀做參考幀
--no-cabac              關閉內容自適應二進制算術編碼(CABAC,高效率的熵編碼)(會提高速度,但嚴重影響質量)
-r/--ref          最大參考幀數,範圍0~16,默認1
--no-deblock            關閉環路濾波(一種除馬賽克算法)
-f/--filter 設置環路濾波的AlphaC和Beta的參數,範圍-6-6,默認都爲0
--interlaced 啓用純交錯模式(用於隔行掃描的源)
碼率控制選項:
-q/--qp  固定量化模式並設置使用的量化值,範圍0~51,0爲無損壓縮,默認26
-B/--bitrate  設置平均碼率
--crf  質量模式,量化值動態可變
--vbv-maxrate  平均碼率模式下,最大瞬時碼率,默認0(與-B設置相同)
--vbv-bufsize  碼率控制緩衝區的大小,單位kbit,默認0
--vbv-init  碼率控制緩衝區數據保留的最大數據量與緩衝區大小之比,範圍0~1.0,默認0.9
--qpmin  設置最小量化值,範圍0~51,默認10
--qpmax  設置最大量化值,範圍0~51,默認51
--qpstep  設置相鄰幀之間的量化值差,範圍0~50,默認4
--ratetol  平均碼率模式下,瞬時碼率可以偏離的倍數,範圍0.1~100.0,默認1.0
--ipratio  I幀和P幀之間的量化係數,默認1.40
--pbratio  P幀和B幀之間的量化係數,默認1.30
--chroma-qp-offset  色度和亮度之間的量化差,範圍-12~+12,默認0
--aq-mode      自適應量化模式,可以在1幀中不同宏塊間重新分配量化值,能提高暗部細節,但會提高碼率。與--qp不能同時使用,0關閉,1開啓,默認1
--aq-strength    AQ強度,減小低細節宏塊的量化值,默認1.0
-p/--pass  多次壓縮碼率控制
1:第一次壓縮,創建統計文件
2:按建立的統計文件壓縮並輸出,不覆蓋統計文件,
3:按建立的統計文件壓縮,優化統計文件
--stats  統計文件的名稱,默認"x264_2pass.log"
--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 //… 分段量化,格式爲:,,,可選項爲:q=(量化值)或b=(碼率倍數)
--qpfile       強制幀的類型和量化值
分析選項:
-A/--analyse  動態塊劃分方法,默認"p8x8,b8x8,i8x8,i4x4"。可選項:p8x8/p4x4/b8x8/i8x8/i4x4;none/all(p4x4需要p8x8. i8x8需要--8x8dct)
--direct        動態預測方式,默認"spatial"。可選項:none/spatial/temporal/auto
--direct-8x8    動態預測方式宏塊大小。 0: 4x4、1: 8x8、-1:儘可能減小體積,默認1
-w/--weightb 允許B幀加權預測(可以減少相鄰B幀質量低的影響)
--me  對全像素塊動態預測搜索的方式,默認"hex",可選項:
dia:菱形搜索,半徑1 (快)
hex:正六邊形搜索,半徑2
umh:可變半徑六邊形搜索
esa:全面搜索(很慢,而且效果與umh幾乎相同)
tesa: 用hadamard方式進行全面搜索,比esa更慢
--merange  --me爲umh/esa時的搜索半徑,最大64,默認16
--mvrange      設置運動矢量的最大範圍,默認-1(自動確定)
--mvrange-thread   線程間最小緩衝,用於一些播放器的兼容性,默認-1(自動確定)
-m/--subme  動態預測和分區方式,可選項1~9,默認6(與壓縮質量和時間關係密切,1是7速度的四倍以上)
1:用全像素塊進行動態搜索,對每個塊再用快速模式進行四分之一像素塊精確搜索
2:用半像素塊進行動態搜索,對每個塊再用快速模式進行四分之一像素塊精確搜索
3:用半像素塊進行動態搜索,對每個塊再用質量模式進行四分之一像素塊精確搜索
4:用快速模式進行四分之一像素塊精確搜索
5:用質量模式進行四分之一像素塊精確搜索
6:進行I、P幀像素塊的速率失真最優化(rdo)
7:進行全部幀像素塊的速率失真最優化
8:進行I、P幀運動矢量及塊內部的速率失真最優化
9:進行全部幀運動矢量及塊內部的速率失真最優化(質量最好)
--psy-rd 在rdo中使用Psy算法(一種心理視覺模型)和Psy-Trellis量化,可提高細節,但會大幅提高碼率。需要-m>6。默認 ["1.0:0.0"]。第一個值爲Psy-rdo強度,第二個值爲Psy-Trellis強度。
--mixed-refs 可以在一幀內使用不同參考幀
--no-chroma-me 不進行色度的動態預測
-8/--8x8dct 可以使用8x8的離散餘弦變換(DCT)
-t/--trellis      Trellis量化,對每個8x8的塊尋找合適的量化值,需要CABAC,默認0
0:關閉
1:只在最後編碼時使用
2:一直使用
--no-fast-pskip 關閉快速P幀跳過檢測
--no-dct-decimate       關閉P幀聯合編碼(可以增加細節,但也會增大體積)
--nr  噪聲去除,範圍0~100000,默認0
--deadzone-inter   設置inter模式下,亮度死區量化值,範圍0~32,默認21。
--deadzone-intra   設置intra模式下,亮度死區量化值,範圍0~32,默認11。
--cqm  設置外部量化矩陣格式,默認"flat",可選項:jvt/flat
--cqmfile  讀取JM格式的外部量化矩陣文件,自動忽略其他--cqm*選項
--cqm4  設置4x4的量化矩陣,用逗號分開,範圍1~255的16個整數
--cqm8  設置8x8的量化矩陣,用逗號分開,範圍1~255的64個整數
--cqm4i/--cqm4p/--cqm8i/--cqm8p 設置I、P幀不同的量化矩陣
--cqm4iy/--cqm4ic/--cqm4py/--cqm4pc 設置亮度、色度不同的量化矩陣
視頻標準化選項:
這些選項與編碼無關,不過如果要用mp4之類的播放器,可以設置,風險自擔
--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
輸入、輸出選項:
-o/--output 指定輸出文件
--sar width:height 設置採樣比例設置,表示採樣像素長寬比
--fps  設定幀率
--seek  設定起始幀
--frames  最大編碼幀數
--level  類似於MPEG4裏的"profile&level",表示編/解碼等級
-v/--verbose 顯示每一個幀的信息
--progress 顯示編碼進程
--quiet 安靜模式
--no-psnr 關閉PSNR計算
--no-ssim            關閉SSIM計算
--threads  編碼線程(使用多線程技術)
--thread-input 在自有線程中運行Avisynth
--non-deterministic   非確定性。可以稍微減少多線程的開銷
--asm  覆蓋CPU檢測
--no-asm 關閉全部CPU優化指令
--visualize 顯示編碼幀信息圖,和XVID類似
--dump-yuv    保存幀爲yuv格式
--sps-id  設置SPS和PPS的ID值,默認0
--aud 使用數據定義符號
若在測試的時候,沒有輸入寬度和高度,會出現:
x264 [error]: Rawyuv input requires a resolution.
若沒有指定 options 則會出現:
x264 [error]: no ratecontrol method specified
x264 [error]: x264_encoder_open failed
這時加上ratecontrol選項即可編碼。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章