CoreAVC for Linux 安裝指南
隨著高清視頻的逐漸流行,對于 H264 解碼器的性能要求也越來越高。 由于缺乏廠商支持,F(xiàn)Fmpeg 中的 ffh264 解碼器由于解碼效率不高,使得一些 CPU 配置較低的機子無法進行高清回放。如果你為此困擾,請參看 Linux 下高清視頻回放 一文。本文將介紹如何將以 CoreAVC for Linux 應(yīng)用到 MPlayer 中。
如果您的顯卡不支持 nVidia 顯卡獨有的 GPU 解碼 VDPAU(或者由于各種錯誤無法使用,如本人),而且 FFmpeg-mt 的 git 慢如牛速(怨念……還是本人……),此時 CoreAVC for Linux 成為了唯一的選擇。全文將以 CoreAVC for Linux 維基為基礎(chǔ), 以Fedora 10 i386 系統(tǒng)為例介紹如何在 Linux 下使用 CoreAVC 解碼器(亦可用于 X86_64 架構(gòu))。
需求條件:
1. CoreAVC 1.7 以上專業(yè)版及注冊碼
需要在 CoreAVC 購買,花費$15,可以拜托有 PayPal 的朋友代購……
2.Mplayer 的近期 SVN 版本,1.0rc2 不行。
推薦下載 MPlayer 每日更新的 SVN export 版本,速度比 svn 快。
3.必要的工具和開發(fā)包
su -c 'yum install subversion gcc make p7zip-plugins libXv-devel pulseaudio-libs-devel alsa-libs-devel libogg-devel ccache'
最后的 ccache 不是必須,但強烈推薦!
假設(shè)與該過程有關(guān)的 CoreAVC 安裝文件和 MPlayer 源代碼包都放在一個目錄下,比如用戶主目錄下的 Build 目錄下:
mkdir -pv $HOME/Build
其他目錄也可以,只要自己別找不到東西了~
1.在 Build 目錄下使用 svn 獲得最新的 CoreAVC for Linux :
svn checkout linux.googlecode.com/svn/trunk/">http://coreavc-for-linux.googlecode.com/svn/trunk/ coreavc-for-linux
2.上一步完成后會在當(dāng)前目錄下生成一個名為 coreavc-for-linux 的目錄,進入它:
cd coreavc-for-linux
3.安裝 dshowserver。
i386 平臺可以直接:
make -C dshowserver
如果沒有提示錯誤的話就可以安裝:
su -c 'cp -v dshowserver/dshowserver /usr/local/bin'
su -c 'cp -v dshowserver/registercodec /usr/local/bin'
X86_64 平臺的建議從這里下載已經(jīng)編譯好的,解壓縮后同樣使用上面的命令復(fù)制到 /usr/local/bin 下。
4.安裝 CoreAVCDecoder.ax 解碼器。
返回 Build 目錄,假設(shè) CoreAVC 安裝文件保存在此目錄下:
cd $HOME/Build
使用 7z 解壓 CoreAVC 安裝文件
7z x coreavc_professional_edition-setup.exe CoreAVCDecoder.ax
無錯誤的話可以在當(dāng)前目錄下找到名為 CoreAVCDecoder.ax 的文件。
現(xiàn)在 MPlayer 等播放器對于附件的二進制編碼器的默認(rèn)安裝目錄是 codecs,為了和官方維基盡量保持一致,在此創(chuàng)建由 codecs 指向 win32 的符號聯(lián)結(jié):
su -c 'ln -vs /usr/lib/codecs /usr/lib/win32'
復(fù)制 CoreAVCDecoder.ax 到此目錄。
su -c 'cp -v CoreAVCDecoder.ax /usr/lib/win32/'
5.注冊 CoreAVCDecoder.ax
如果之前沒有使用過 MPlayer 的話,需要創(chuàng)建用戶配置文件目錄,使用過的話可以跳過:
mkdir-pv $HOME/.mplayer
將保存 MPlayer 配置信息的 $HOME/.mplayer 目錄關(guān)聯(lián)為注冊表:
export REGISTRY=$HOME/.mplayer/registry32
輸入注冊碼,用你獲得的注冊碼替代下面命令中的 55555-55555-CORE-55555-55555,注意雙引號需要保留:
registercodec -r $REGISTRY -k "HKLM\\Software\\CoreCodec\\CoreAVC Pro\\Serial" -v "55555-55555-CORE-55555-55555"
#p#
6.用 dshowserver 測試是否注冊成功:
dshowserver -c CoreAVCDecoder.ax -s 1280x720 -g 09571a4b-f1fe-4c60-9760de6d310c7c31 -b 12 -f 0x34363248 -o 0x30323449
得到的輸出結(jié)果應(yīng)該是:
No id specified, assuming test mode
Opening device
len: 992
ProductVersion: 1.7.0
Decoder supports the following YUV formats: YUY2 UYVY YV12 I420
Decoder is capable of YUV output (flags 0x2b)
Setting fmt
Starting
Initialization is complete
如果使用的是 1.9.0 版本的 CoreAVC 的話,輸出結(jié)果應(yīng)該是:
No id specified, assuming test mode
Opening device
Called unk_IsDebuggerPresent
len: 992
ProductVersion: 1.9.0
Win32 LoadLibrary failed to load: nvcuvid.dll, /usr/lib/win32/nvcuvid.dll, /usr/local/lib/win32/nvcuvid.dll
Decoder supports the following YUV formats: YUY2 UYVY YV12 I420
Decoder is capable of YUV output (flags 0x2b)
Setting fmt
Starting
Initialization is complete
此時你可以選擇在這里下載它提示缺失的 nvcuvid.dll,然后復(fù)制到 /usr/lib/win32 目錄下
7z x dgmpgdecnv100b.zip nvcuvid.dll
su -c 'cp -v nvcuvid.dll /usr/lib/win32/'
不過經(jīng)個人測試這個 dll 文件沒什么用處:它是 CoreAVC 1.9 在 Windows 平臺下利用 CUDPA GPU 計算加快解碼速度的接口,在 Linux 平臺下不會起什么作用的……
7.編譯并安裝 MPlayer
首先當(dāng)然是解壓縮源代碼包:
tar xf mplayer-export-snapshot.tar.bz2
之后進入所在MPlayer 源代碼目錄:
cd mplayer-export-*
生成編譯配置文件:
/configure --disable-x264 --disable-x264-lavc --language=zh_CN
如果沒有提示錯誤的話,就打上 CoreAVC for Linux 的補?。?BR>patch -p0 ../coreavc-for-linux/mplayer/dshowserver.patch
如果沒有提示錯誤的話,就可以開始編譯了,首次編譯大概需要15分鐘左右,以后源代碼包更新時有 ccache 幫助就會快很多:
make
如果沒有提示錯誤的話,就可以安裝了:
su -c 'make install'
8.配置解碼器預(yù)置文件
將默認(rèn)配置文件復(fù)制到MPlayer用戶配置文件目錄下,注意是 etc/codec.conf(也就是當(dāng)前MPlayer 源代碼下的 etc 目錄),而不是 /etc/codec.conf (這個是系統(tǒng)etc目錄):
cp -v etc/codecs.conf $HOME/.mplayer/
使用任意文本編輯器修改此文件,比如 gedit:
gedit $HOME/.mplayer/codecs.conf
之后將以下內(nèi)容
videocodec coreserve
info "CoreAVC DShow H264 decoder 1.3 for x86 - status working
format 0x10000005
fourcc H264,h264 H264
fourcc X264,x264
fourcc avc1,AVC1 AVC1
fourcc davc,DAVC
fourcc VSSH
driver dshowserver
dll "CoreAVCDecoder.ax"
guid 0x09571a4b, 0xf1fe, 0x4c60, 0x97, 0x60, 0xde, 0x6d, 0x31, 0x0c, 0x7c, 0x31
out YV12,IYUV,I420,YUY2
添加到
;=============================================================================
; VIDEO CODECS
;=============================================================================
之后,并且與下一個 videocodec 之間空一行。保存退出。
至此, CoreAVC for Linux 應(yīng)用于 MPlayer 的過程結(jié)束
9.(可選)配置 SMPlayer
(1)確定使用正確的 MPlayer 版本:
“選項“-”首選項“-“常規(guī)”,在“常規(guī)”選項卡的“選擇 MPlayer 的可執(zhí)行文件“中輸入
/usr/local/bin/mplayer
(2)取消 Draw video using slices:
“選項“-”首選項“-“常規(guī)”,在“視頻“選項卡中取消”Draw video using slices”。
(3)取消 CoreAVC 不支持的反拉絲,并讓 CoreAVC 自己決定后期處理級別:
“選項“-”首選項“-“常規(guī)”,在“視頻“選項卡中將反拉絲設(shè)為“無“,取消“為所有視頻啟用后期處理”。
(4)關(guān)閉會導(dǎo)致錯誤的 Correct PTS 選項:
“選項“-”首選項“-“高級”,在“高級“選項卡中取消“Correct PTS“。
點擊“確定“保存退出。
當(dāng)播放高清視頻時點擊“信息“后,若是顯示在“視頻“-”選擇編碼器“中顯示”coreserve“,恭喜你,成功了!
ffh264 與 CoreAVC 解碼效率對比:
根據(jù) MPlayer man 手冊的建議,對手頭的 輻射3官方720P 宣傳片進行測試。
使用 ffh264 時:
mplayer -benchmark -vo null -nosound -vc ffh264 fallout3_HD.mp4
原始輸出:
MPlayer SVN-r28764-snapshot-4.3.2 (C) 2000-2009 MPlayer Team
137 audio & 297 video codecs
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing fallout3_HD.mp4.
libavformat file format detected.
[lavf] Audio stream found, -aid 0
[lavf] Video stream found, -vid 1
VIDEO: [avc1] 1280×720 24bpp 29.970 fps 0.0 kbps ( 0.0 kbyte/s)
Clip info:
name: Fallout 3 Official Trailer
==========================================================================
Forced video codec: ffh264
Opening video decoder: [ffmpeg] FFmpeg’s libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
Audio: no sound
Starting playback…
VDec: vo config request - 1280 x 720 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
VO: [null] 1280×720 => 1280×720 Planar YV12
V: 193.7 0/ 0 41% 0% 0.0% 0 0
BENCHMARKs: VC: 80.627s VO: 0.023s A: 0.000s Sys: 1.091s = 81.741s
BENCHMARK%: VC: 98.6373% VO: 0.0278% A: 0.0000% Sys: 1.3349% = 100.0000%
Exiting… (End of file)
使用 CoreAVC 時:
mplayer -benchmark -vo null -nosound -vc coreserve fallout3_HD.mp4
原始輸出:
MPlayer SVN-r28764-snapshot-4.3.2 (C) 2000-2009 MPlayer Team
137 audio & 297 video codecs
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing fallout3_HD.mp4.
libavformat file format detected.
[lavf] Audio stream found, -aid 0
[lavf] Video stream found, -vid 1
VIDEO: [avc1] 1280×720 24bpp 29.970 fps 0.0 kbps ( 0.0 kbyte/s)
Clip info:
name: Fallout 3 Official Trailer
==========================================================================
Forced video codec: coreserve
Opening video decoder: [dshowserver] DirectShowServer video codecs
Opening device
Called unk_IsDebuggerPresent
len: 992
ProductVersion: 1.9.0
Decoder supports the following YUV formats: YUY2 UYVY YV12 I420
Decoder is capable of YUV output (flags 0×2b)
Setting fmt
Starting
Initialization is complete
VDec: vo config request - 1280 x 720 (preferred colorspace: Packed YUY2)
[PP] Using codec’s postprocessing, max q = 4.
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
VO: [null] 1280×720 => 1280×720 Planar YV12
Found DirectShow filterSelected video codec: [coreserve] vfm: dshowserver (CoreAVC DShow H264 decoder 1.3 for x86 - http://corecodec.org/)
==========================================================================
Audio: no sound
Starting playback…
Dshowserver Connected to host
pts value < previous ??% ??,?% 0 0
V: 193.6 0/ 0 22% 0% 0.0% 0 0
BENCHMARKs: VC: 43.521s VO: 0.024s A: 0.000s Sys: 1.697s = 45.241s
BENCHMARK%: VC: 96.1975% VO: 0.0525% A: 0.0000% Sys: 3.7499% = 100.0000%
Destroying filter
Exiting… (End of file)
根據(jù)此文中對各項結(jié)果的說明,可以看出使用 CoreAVC 可以使用戶空間上解碼所用時間從 ffh264 的 80.627s 下降到 43.521s,也就是說速度提升了46%((80.627-43.521)/80.627)!只是在內(nèi)核空間上有小幅度的提升,從ffh264 的 1.091s 升高到1.697s。據(jù)此可見 CoreAVC 的解碼效率還是相當(dāng)驚人的。
總結(jié)
個人使用了一些 720P 的片子測試,做為一款需要掏錢的解碼器,畫面效果相當(dāng)出色,也沒有跳幀的現(xiàn)象發(fā)生,但是 CPU 占有率并沒有明顯下降,是由于 CoreAVC 會在能保持流暢的時候使用剩余 CPU 資源去做畫質(zhì)后處理。在本人 Turion 64 X2 TL-58 /DDR2 800 2*2GB / GeForce 8400M G 128M 的機子上 CPU 占有率在 40% 至 90% 間浮動。沒有 1080P 的資源,不知道此時的 CPU 占有率如何。
如果你的 CPU 性能不錯但是顯卡不被 VDPAU 支持,并且無法忍受 ffmpeg-mt git 1b/s 的下載速度,那么 CoreAVC 的確是目前在 Linux 播放高清視頻的最佳選擇。
附:如何在 Windows 平臺上的 SMPlayer 中使用 CoreAVC
1.到這里下載帶有 CoreAVC 支持的 MPlayer 可執(zhí)行文件。
2.用上面下載的 mplayer.exe 覆蓋掉 SMPlayer for Windows 安裝時附帶的 mplayer.exe。
3.將 CoreAVC 安裝目錄下的 CoreAVCDecoder.ax 文件復(fù)制到 SMlayer 目錄下的 codec 目錄中。
4.執(zhí)行上文 SMPlayer 配置中(2)(3)(4)。
5.在 SMPlayer 的 “選項“-”首選項“-“高級”,在“MPlayer選項“選項卡中的“選項“處填入-vc coreavc,,注意不要漏掉最后的逗號!
【編輯推薦】