Open Access.放一些我有興趣的東西或是事物.
官方網站 http://abraxas.no-ip.org/ezbuilder 更詳細介紹,請入內觀看.
ezbuilder是一個avs檔(avisynth script)與bat批次作業檔(batch)產生器,用來建立電影轉檔所需要的avs檔與處理流程.
只要你會撰寫avs檔,並且懂得利用工具將工具的指令化處理流程寫在批次檔定義的profile中,透過avs與bat批次檔的搭配就能非常方便而且輕鬆地一次處理多個檔案.
這是我自己寫的工具軟體,個人覺得文字操作介面雖然陽春,但是操作感上非常上手.
這邊依照使用者習慣不同,也會有不同習慣使用的工具,我通常是使用avs2wav,其他還有一些類似的工具,這種工具的主要目的,是用來開啟avs檔,將avs檔聲音的部分stdout輸出,主要是用來搭配audio的encoder,如果audio encoder(好比說neroaacenc)有支援stdin的讀取功能,就可以利用這個工具直接將avs聲音的部分匯入到audio encoder端處理壓縮.
avs2wav這工具 http://www.avisynth.info/?avs2wav 裡頭有下載處連結與更詳細介紹.
Avisynth 官方網站 http://avisynth.org/mediawiki/Main_Page
下載頁面 http://sourceforge.net/project/showfiles.php?group_id=57023
這款軟體是非常重要也是常被用的軟體,軟體功能為提供一個frame server機制,你可以建立一個所謂avisynth script檔案( *.avs ),透過這個script的語法與處理幫助你開啟一個影音檔,avisynth本身提供許多濾鏡(filter)與可程式化功能,另外亦提供動態連結庫載入功能,幫助你擴充它的功能,有了這些能力就可以利用它去間接開啟一個影音檔,player軟體若是支援avisynth script的播放,播放的過程就會透過avs搭配上script裡面所撰寫的filter與程式加強播放的效果,由於encoder端幾乎沒有任何額外的filter處理功能,encoder搭配上avs後可以說是如魚得水,因此avs搭配上encoder可以說是現在處理方法的主流了.
網路上有很多avisynth的教學,而這邊來說一下我使用的習慣,通常會使用 DirectShowSource 來開啟所有被系統影音code所支援的影音視訊檔案,你windows media player可以播放的檔案,DirectShowSource 就可以開啟.
x.264是MPEG4 AVC(h.264)的 encoder
官方網站 http://x264.nl
x264.exe --help 會列出所有的操作參數模式,如下
往後會有使用教學
===============================================
x264 core:59 r830 5ca01b3
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 (yes).
Outfile type is selected by filename:
.264 -> Raw bytestream
.mkv -> Matroska
.mp4 -> MP4 if compiled with GPAC support (yes)
Options:
-h, --help List the more commonly used options
--longhelp List all options
Frame-type options:
-I, --keyint <integer> Maximum GOP size [250]
-b, --bframes <integer> Number of B-frames between I and P [0]
--b-pyramid Keep some B-frames as references
--no-cabac Disable CABAC
-r, --ref <integer> Number of reference frames [1]
-f, --deblock <alpha:beta> Loop filter AlphaC0 and Beta parameters [0:0]
--interlaced Enable pure-interlaced mode
Ratecontrol:
-q, --qp <integer> Set QP (0=lossless) [26]
-B, --bitrate <integer> Set bitrate (kbit/s)
--crf <float> Quality-based VBR (nominal QP)
--vbv-bufsize <integer> Enable CBR and set size of the VBV buffer (kbit) [0]
--ratetol <float> Allowed variance of average bitrate [1.0]
--ipratio <float> QP factor between I and P [1.40]
--pbratio <float> QP factor between P and B [1.30]
--aq-mode <integer> How AQ distributes bits [2]
- 0: Disabled
- 1: Avoid moving bits between frames
- 2: Move bits between frames
--aq-strength <float> Reduces blocking and blurring in flat and
textured areas. [1.0]
- 0.5: weak AQ
- 1.5: strong AQ
-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
--stats <string> Filename for 2 pass stats ["x264_2pass.log"]
--qcomp <float> QP curve compression: 0.0 => CBR, 1.0 => CQP [0.60]
--zones <zone0>/<zone1>/... Tweak the bitrate of some regions of the video
Analysis:
-A, --partitions <string> Partitions to consider ["p8x8,b8x8,i8x8,i4x4"]
- p8x8, p4x4, b8x8, i8x8, i4x4
- none, all
(p4x4 requires p8x8. i8x8 requires --8x8dct.)
--direct <string> Direct MV prediction mode ["spatial"]
- none, spatial, temporal, auto
-w, --weightb Weighted prediction for B-frames
--me <string> Integer pixel motion estimation method ["hex"]
- dia, hex, umh
--merange <integer> Maximum motion vector search range [16]
-m, --subme <integer> 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 <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
--no-fast-pskip Disables early SKIP detection on P-frames
--no-dct-decimate Disables coefficient thresholding on P-frames
--nr <integer> Noise reduction [0]
--cqmfile <string> Read custom quant matrices from a JM-compatible file
Input/Output:
-o, --output Specify output file
--sar width:height Specify Sample Aspect Ratio
--fps <float|rational> Specify framerate
--seek <integer> First frame to encode
--frames <integer> Maximum number of frames to encode
--level <string> 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 <integer> Parallel encoding
--thread-input Run Avisynth in its own thread
===============================================
最重要的就是了解播放裝置的播放能力上限,以及利用工具製造出適當的檔案規格.
1.了解這款播放裝置所能接受的解析度,通常以播放裝置螢幕的解析度為準,但這個視實際狀況而定,最理想的還是直接支援螢幕原生解析度為最佳狀況.
2.了解這款播放裝置所能接受的最高播放率,某些player不支援超過某範圍的播放率(fps),某些只接受某些播放率,某些雖然沒有限制,卻會因為硬體性能而造成lag問題,這些都要經過測試或是參考官方所給的明確數據才能了解,case by case.
3.了解這款播放裝置解碼能力上限,除了參考官方所給予的參考數據外,還得自己實際測試,因為每款裝置的硬體解碼性能不同,因此所能接受的碼率也不同,有些解碼性能強大甚至超過官方所給的數據限制,最理想的狀況是此款player足以應付極劇烈畫面場景所產生的流量率(quantizr模式).
4.了解這款播放裝置所接受的影音規格與封包容器,特別強調同樣是mpeg4,但是卻可能因為支援的profile不同而導致相容性的問題,好比說多數的player通常只支援simple profile(no gmc.no bframe.no qp).
5.了解這款播放裝置有無特殊保護或是加密,諸如ipod與psp(早期)就會在檔案標頭上動手腳,某種保護自家轉檔軟體的封閉意味.
以上5點徹底了解後,就開始見招拆招,反覆測試找尋最佳方案,來建立最適合某款player的轉檔方式.
mp4box是一款將資料封裝入MP4容器的程式工具.
官方網站 http://gpac.sourceforge.net/index.php
這邊提供編譯好的版本 http://www.videohelp.com/tools/mp4box
MP4容器目前是最多掌上型裝置所支援的檔案規格,操作參數就不列了.
往後會有直接實例教學.
http://www.nero.com/cht/nero-aac-codec.html
AAC是一種音訊編碼的方式,而同樣是AAC又細分成不同的實作層級,隨著實作層級的規格不同,維持同樣品質的壓縮率也不同,LC-AAC(約略接近MP3) . HE-AAC(約略接近MP3 PRO) . AAC Plus V2(適合於極低流率),目前AAC Encoder中最完整的就是nero公司提供的編碼器.
至於其他encoder通常是以libfaac為核心,僅只支援LC-AAC,而且還有bug....有時候這種bug會造成你建立的影片檔因為音訊錯誤的關係,直接跳出,所以目前aac編碼我只推薦用這款.
如果電腦cpu有sse2多媒體指令集功能,可以使用neroaacenc其中的sse2最佳化版本 neroAacEnc_SSE.exe.
neroAacEnc.exe -help 會列出所有的操作參數模式,如下
往後會有使用教學
===============================================
*************************************************************
* *
* Nero Digital Audio Reference MPEG-4 & 3GPP Audio Encoder *
* Copyright 2007 Nero AG *
* All Rights Reserved Worldwide *
* *
* Package build date: Aug 6 2007 *
* Package version: 1.1.34.2 *
* *
* See -help for a complete list of available parameters. *
* *
*************************************************************
Usage:
C:\Documents and Settings\abraxas\??\NeroDigitalAudio\win32\neroAacEnc.exe [opti
ons] -if -of
Where:
: Path to source file to encode.
The file must be in Microsoft WAV format and contain PCM data.
Specify - to encode from stdin.
Note that multiple input files can be specified, they will be
encoded together into a single output file with chapter marks
indicating source file divisions.
: Path to output file to encode to, in MP4 format.
==== Available options: ====
Quality/bitrate control:
-q : Enables "target quality" mode.
is a floating-point number in 0...1 range.
-br : Specifies "target bitrate" mode.
is target bitrate in bits per second.
-cbr : Specifies "target bitrate (streaming)" mode.
is target bitrate in bits per second.
When neither of above quality/bitrate options is used,
the encoder defaults to equivalent of -q 0.5
Multipass encoding:
-2pass : Enables two-pass encoding mode.
Note that two-pass more requires a physical file as input,
rather than stdin.
-2passperiod : Overrides two-pass encoding bitrate averaging period,
: in milliseconds.
: Specify zero to use least restrictive value possible (default).
Advanced features / troubleshooting:
-lc : Forces use of LC AAC profile (HE features disabled)
-he : Forces use of HE AAC profile (HEv2 features disabled)
-hev2 : Forces use of HEv2 AAC profile
Note that the above switches (-lc, -he, -hev2) should not be
used; optimal AAC profile is automatically determined from
quality/bitrate settings when no override is specified.
-ignorelength : Ignores length signaled by WAV headers of input file.
Useful for certain frontends using stdin.
===============================================
XVID 是一個MPEG4的CODEC(具備解碼與編碼功能),通常這邊比較關切的是在encoder這方面的議題.
xvid是一個最好的encoder,另外還有一個東西叫做 xvid cli (xvid_encraw),算是一個xvid指令介面操作的前導軟體.
XVID官方網站 http://www.xvid.org
因為官方站沒提供編譯好的版本下載(只有原始碼),安裝檔可以在下面網址下載
http://www.xvidmovies.com/codec
xvid cli前導工具 xvid_encraw 不知道官方網站在哪,自己google一下吧.
xvid_encraw.exe -help 會列出xvid_encraw 所有的操作參數如下
往後會介紹一下一些重要的編碼優化設定參數.
===============================================
xvid_encraw built at 17:33:35 on Apr 30 2006
Usage : xvid_encraw [OPTIONS]
Input options:
-i string : input filename (stdin)
-type integer: input data type (yuv=0, pgm=1, avi/avs=2)
-w integer: frame width ([1.2048])
-h integer: frame height ([1.2048])
-frames integer: number of frames to encode
Output options:
-dump : save decoder output
-save : save an Elementary Stream file per frame
-o string : save an Elementary Stream for the complete sequence
-avi string: save an AVI file for the complete sequence
-mkv string: save a MKV file for the complete sequence
BFrames options:
-max_bframes integer: max bframes (2)
-bquant_ratio integer: bframe quantizer ratio (150)
-bquant_offset integer: bframe quantizer offset (100)
Rate control options:
-framerate float : target framerate (25.0)
-bitrate [integer] : target bitrate in kbps (700)
-size integer : target size in kilobytes
-single : single pass mode (default)
-cq float : single pass constant quantizer
-pass1 [filename] : twopass mode (first pass)
-full1pass : perform full first pass
-pass2 [filename] : twopass mode (2nd pass)
-zq starting_frame float : bitrate zone; quant
-zw starting_frame float : bitrate zone; weight
-max_key_interval integer : maximum keyframe interval (300)
Single Pass options:
-reaction integer : reaction delay factor (16)
-averaging integer : averaging period (100)
-smoother integer : smoothing buffer (100)
Second Pass options:
-kboost integer : I frame boost (10)
-kthresh integer : I frame reduction threshold (1)
-kreduction integer : I frame reduction amount (20)
-ostrength integer : overflow control strength (5)
-oimprove integer : max overflow improvement (5)
-odegrade integer : max overflow degradation (5)
-chigh integer : high bitrate scenes degradation (
-clow integer : low bitrate scenes improvement (0
-overhead integer : container frame overhead (24)
-vbvsize integer : use vbv buffer size
-vbvmax integer : vbv max bitrate
-vbvpeak integer : vbv peak bitrate over 1 second
Other options
-noasm : do not use assembly optmized code
-turbo : use turbo presets for higher enco
-quality integer : quality ([0..6]) (6)
-vhqmode integer : level of R-D optimizations ([0..4
-bvhq : use R-D optimizations for B-frame
-qpel : use quarter pixel ME
-gmc : use global motion compensation
-qtype integer : quantization type (H263:0, MPEG4:
-qmatrix filename : use custom MPEG4 quantization mat
-interlaced [integer] : interlaced encoding (BFF:1, TFF:2
-nopacked : Disable packed mode
-noclosed_gop : Disable closed GOP mode
-lumimasking : use lumimasking algorithm
-stats : print stats about encoded frames
-debug : activates xvidcore internal debug
-vop_debug : print some info directly into enc
-nochromame : Disable chroma motion estimation
-notrellis : Disable trellis quantization
-imin integer : Minimum I Quantizer (1..31) (2)
-imax integer : Maximum I quantizer (1..31) (31)
-bmin integer : Minimum B Quantizer (1..31) (2)
-bmax integer : Maximum B quantizer (1..31) (31)
-pmin integer : Minimum P Quantizer (1..31) (2)
-pmax integer : Maximum P quantizer (1..31) (31)
-drop integer : Frame Drop Ratio (0..100) (0)
-start integer : Starting frame number
-threads integer : Number of threads
-progress [integer] : Show progress updates every n fra
-par integer[:integer] : Set Pixel Aspect Ratio.
1 = 1:1
2 = 12:11 (4:3 PAL)
3 = 10:11 (4:3 NTSC)
4 = 16:11 (16:9 PAL)
5 = 40:33 (16:9 NTSC)
other = custom (width:height)
-help : prints this help message
NB: You can define 64 zones repeating the -z[qw] option as needed.
===============================================
普遍來說,分成CBR.ABR.2-PASS.Quantizr.
CBR(constant bitrate rate,固定比特率)跟ABR(average bitrate rate),兩個很接近但是又不太一樣,反正大概就是說cbr是以每秒為單位,在這一秒內資料量的平均比率是固定的,而ABR則是更有彈性,可能是某個時間區段內,平均起來的流量比率是固定的,總之這兩種方式可以達成以播放時間來預測所產生的檔案大小,隨著設定的參數大小,可以約略精準地預測或是設定檔案大小.
2-PASS,大概的意思是說一個視訊先經過壓縮估算,計算出每一張frame(畫面)壓縮所需要的資料量,並且紀錄下這些資料量資訊(2-pass中的第一次pass階段),求得這些資訊後,經過某些演算法,依照某些特殊的需求,制定出合理的流量分配方法給每張frame,通常2-pass可以辦到限制最高與最低流量的界線(對於一些硬體解碼能力有限制的player,限制播放流量上限是需要的)以及設定最終壓縮出來的檔案大小,與2-pass類似的還有n-pass,反正就是類似的概念.
Quantizer,以固定品質(量化參數是固定的)為基礎的一種流量分配模式,這種分配模式也可視為是沒有方式的方式,流量依照畫面的複雜度隨時改變,一般而言算是最有效率的流量模式.
這也是新手常常會搞混的問題.
容器意思是說用來放置特殊code資料的儲存型態,當然它也會是一個檔案,譬如說MP4.AVI.RM.RMVB.MKV.OGM都是一種容器,至於這些容器裡面會放什麼東西擇不一定,而每一種容器可以放置的CODE資料又不一定,好比說RM.RMVB這兩種容器格式皆以放置real公司所開發的影音code為主,而MP4通常來說"習慣上"(實際上沒有綁死)放置MPEG4或是MPEG4 AVC這兩種視訊編碼資料,各容器一些細部的說明略談,但是概念要有,因此別再傻傻問說,為什麼同樣是AVI檔但是一個能放.一個卻不能放,因為容器雖然相同,但是內容不同.
CODE,前面有提過了,就不提了.