歡迎您光臨本站 註冊首頁

系統安裝:CoreAVC for Linux 安裝指南

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

隨著高清視頻的逐漸流行,對於 H264 解碼器的性能要求也越來越高. 由於缺乏廠商支持,FFmpeg 中的 ffh264 解碼器由於解碼效率不高,是的一些 CPU 配置較低的機子無法進行高清回放.如果你為此困擾,請參看 Linux 下高清視頻回放 一文.本文將介紹如何將以 CoreAVC for Linux 應用到 MPlayer 中.

  如果您的顯卡不支持 nVidia 顯卡獨有的 GPU 解碼 VDPAU(或者由於各種錯誤無法使用,如本人), FFmpeg-mt 的 git 慢如牛速(怨念……還是本人……),此時 CoreAVC for Linux 成為了唯一的選擇.全文將以 CoreAVC for Linux 維基為基礎, 以Fedora 10 i386 系統為例介紹如何在 Linux 下使用 CoreAVC 解碼器(亦可用於 X86_64 架構).

  需求條件:

  1. CoreAVC 1.7 以上專業版及註冊碼

  需要在 CoreAVC 購買,花費$15,可以拜託有 PayPal 的朋友代購……

  2.Mplayer 的近期 SVN 版本,1.0rc2 不行.

  推薦下載 MPlayer 每日更新的 SVN export 版本,速度比 svn 快.

  3.必要的工具和開發包

  su -c 'yum install subversion gcc make p7zip-plugins libXv-devel pulseaudio-libs-devel alsa-libs-devel libogg-devel ccache'

  的 ccache 不是必須,但強烈推薦!

  假設與該過程有關的 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.上一步完成後會在當前目錄下生成一個名為 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 平台的建議從這裡下載已經編譯好的,解壓縮后同樣使用上面的命令複製到 /usr/local/bin 下.


4.安裝 CoreAVCDecoder.ax 解碼器.

  返回 Build 目錄,假設 CoreAVC 安裝文件保存在此目錄下:

  cd $HOME/Build

  使用 7z 解壓 CoreAVC 安裝文件

  7z x coreavc_professional_edition-setup.exe CoreAVCDecoder.ax

  無錯誤的話可以在當前目錄下找到名為 CoreAVCDecoder.ax 的文件.

  現在 MPlayer 等播放器對於附件的二進位編碼器的默認安裝目錄是 codecs,為了和官方維基盡量保持一致,在此創建由 codecs 指向 win32 的符號聯結:

  su -c 'ln -vs /usr/lib/codecs /usr/lib/win32'

  複製 CoreAVCDecoder.ax 到此目錄.

  su -c 'cp -v CoreAVCDecoder.ax /usr/lib/win32/'

  5.註冊 CoreAVCDecoder.ax

  如果之前沒有使用過 MPlayer 的話,需要創建用戶配置文件目錄,使用過的話可以跳過:

  mkdir-pv $HOME/.mplayer

  將保存 MPlayer 配置信息的 $HOME/.mplayer 目錄關聯為註冊表:

  export REGISTRY=$HOME/.mplayer/registry32

  輸入註冊碼,用你獲得的註冊碼替代下面命令中的 55555-55555-CORE-55555-55555,注意雙引號需要保留:

  registercodec -r $REGISTRY -k "HKLMSoftwareCoreCodecCoreAVC ProSerial" -v "55555-55555-CORE-55555-55555"

  6.用 dshowserver 測試是否註冊成功:

  dshowserver -c CoreAVCDecoder.ax -s 1280x720 -g 09571a4b-f1fe-4c60-9760de6d310c7c31 -b 12 -f 0x34363248 -o 0x30323449

  得到的輸出結果應該是:

  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 的話,輸出結果應該是:

  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,然後複製到 /usr/lib/win32 目錄下

  7z x dgmpgdecnv100b.zip nvcuvid.dll

  su -c 'cp -v nvcuvid.dll /usr/lib/win32/'

  不過經個人測試這個 dll 文件沒什麼用處:它是 CoreAVC 1.9 在 Windows 平台下利用 CUDPA GPU 計算加快解碼速度的介面,在 Linux 平台下不會起什麼作用的……


7.編譯並安裝 MPlayer

  當然是解壓縮源代碼包:

  tar xf mplayer-export-snapshot.tar.bz2

  之後進入所在MPlayer 源代碼目錄:

  cd mplayer-export-*

  生成編譯配置文件:

  ./configure --disable-x264 --disable-x264-lavc --language=zh_CN

  如果沒有提示錯誤的話,就打上 CoreAVC for Linux 的補丁:

  patch -p0 ../coreavc-for-linux/mplayer/dshowserver.patch

  如果沒有提示錯誤的話,就可以開始編譯了,首次編譯大概需要15分鐘左右,以後源代碼包更新時有 ccache 幫助就會快很多:

  make

  如果沒有提示錯誤的話,就可以安裝了:

  su -c 'make install'

  8.配置解碼器預置文件

  將默認配置文件複製到MPlayer用戶配置文件目錄下,注意是 etc/codec.conf(也就是當前MPlayer 源代碼下的 etc 目錄),而不是 /etc/codec.conf (這個是系統etc目錄):

  cp -v etc/codecs.conf $HOME/.mplayer/

  使用任意文本編輯器修改此文件,比如 gedit:

  gedit $HOME/.mplayer/codecs.conf

  之後將以下內容

  videocodec coreserve

  info "CoreAVC DShow H264 decoder 1.3 for x86 - http://corecodec.org/"

  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 應用於 MPlayer 的過程結束


9.(可選)配置 SMPlayer

  (1)確定使用正確的 MPlayer 版本:

  「選項「-」首選項「-「常規」,在「常規」選項卡的「選擇 MPlayer 的可執行文件「中輸入

  /usr/local/bin/mplayer

  (2)取消 Draw video using slices:

  「選項「-」首選項「-「常規」,在「視頻「選項卡中取消」Draw video using slices」.

  (3)取消 CoreAVC 不支持的反拉絲,並讓 CoreAVC 自己決定後期處理級別:

  「選項「-」首選項「-「常規」,在「視頻「選項卡中將反拉絲設為「無「,取消「為所有視頻啟用後期處理」.

  (4)關閉會導致錯誤的 Correct PTS 選項:

  「選項「-」首選項「-「高級」,在「高級「選項卡中取消「Correct PTS「.

  點擊「確定「保存退出.

  當播放高清視頻時點擊「信息「后,若是顯示在「視頻「-」選擇編碼器「中顯示」coreserve「,恭喜你,成功了!

  ffh264 與 CoreAVC 解碼效率對比:

  根據 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)

  根據此文中對各項結果的說明,可以看出使用 CoreAVC 可以使用戶空間上解碼所用時間從 ffh264 的 80.627s 下降到 43.521s,也就是說速度提升了46%((80.627-43.521)/80.627)!只是在內核空間上有小幅度的提升,從ffh264 的 1.091s 升高到1.697s.據此可見 CoreAVC 的解碼效率還是相當驚人的.


總結

  個人使用了一些 720P 的片子測試,做為一款需要掏錢的解碼器,畫面效果相當出色,也沒有跳幀的現象發生,但是 CPU 佔有率並沒有明顯下降,是由於 CoreAVC 會在能保持流暢的時候使用剩餘 CPU 資源去做畫質后處理.在本人 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 可執行文件.

  2.用上面下載的 mplayer.exe 覆蓋掉 SMPlayer for Windows 安裝時附帶的 mplayer.exe.

  3.將 CoreAVC 安裝目錄下的 CoreAVCDecoder.ax 文件複製到 SMlayer 目錄下的 codec 目錄中.

  4.執行上文 SMPlayer 配置中(2)(3)(4).

  5.在 SMPlayer 的 「選項「-」首選項「-「高級」,在「MPlayer選項「選項卡中的「選項「處填入-vc coreavc,,注意不要漏掉的逗號!


[火星人 ] 系統安裝:CoreAVC for Linux 安裝指南已經有631次圍觀

http://coctec.com/docs/linux/show-post-56250.html