发新话题
打印

ubuntu下低配置看高清 mplayer+win32codecs+Coreavc编译详解

ubuntu下低配置看高清 mplayer+win32codecs+Coreavc编译详解

http://hi.baidu.com/song110/blog ... 3443d69c8204ca.html

正式开始
1. 如何安装win32codecs
比起手动安装来,我更推荐加源安装的方法。medibuntu是目前最好的源。
以ubuntu8.10为例
先加源
代码:
sudo wget http://www.medibuntu.org/sources.list.d/intrepid.list --output-document=/etc/apt/sources.list.d/medibuntu.list

然后加GPG Key
代码:
sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update

这一步时可能会有未验证之类的错误提示,回答yes,或y让它继续进行即可。

安装win32codecs包
如果是intel的CPU
代码:
sudo apt-get install w32codecs

如果是64位 CPU
代码:
sudo apt-get install w64codecs


OK,完成win32codecs的安装

2. 从源里安装mplayer。这一步很重要,因为我们需要用源里的mplayer来确定依赖关系,要不然,编译的mplayer很可能会缺少某些功能。
8.10源里的mplayer仍是1.0rc2,有点老。我们可以加个源用新的
代码:
sudo gedit /etc/apt/sources.list

在末尾加上
代码:
deb http://ppa.launchpad.net/rvm/ubuntu intrepid main
deb-src http://ppa.launchpad.net/rvm/ubuntu intrepid main

保存后
代码:
sudo apt-get update

代码:
sudo apt-get install mplayer smplayer mplayer-fonts  mozilla-mplayer

执行到这一步,不想编译的同学就可以止步了。你将得到一个版本比较新的mplayer和smplayer。但有可能mplayer会有问题。源里的mplayer要稳定得多。

---------------------------------------编译mplayer的快乐分隔线------------------------------------------------------

3. 准备编译mplayer+Coreavc。
第一步(重要)
代码:
sudo apt-get build-dep mplayer


第二步 下载mplayer,下载Coreavc,以及破解版的CoreAVCDecoder.ax。
下载SVN版的mplayer(只有SVN版的mplayer才能安上Coreavc)
代码:
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer


用SVN版下载Coreavc
代码:
svn checkout http://coreavc-for-linux.googlecode.com/svn/trunk/ coreavc-for-linux


下载CoreAVCDecoder.ax破解包。http://sites.google.com/site/ubuntuxuexiexi/Home/mplayer-coreavc。解压后将CoreAVCDecoder.ax拷贝到/usr/lib/codecs目录中,然后更改此文件权限为所有用户可读。
代码:
sudo chmod 644 /usr/lib/codecs/CoreAVCDecoder.ax


第三步 顺序是:处理Coreavc---注册CoreAVCDecoder.ax--配置mplayer--打补丁--编译--完成
a. 处理Coreavc(以intel CPU为例 )
代码:
cd coreavc-for-linux
make -C dshowserver

然后
代码:
sudo cp dshowserver/dshowserver /usr/local/bin
sudo cp dshowserver/registercodec /usr/local/bin

对于64位CPU,应该到http://code.google.com/p/coreavc-for-linux/downloads/list下载最新的包。然后把dshowserver和registercodec拷贝到/usr/local/bin目录中。

b. 注册CoreAVCDecoder.ax
代码:
registercodec -r ~/.mplayer/registry32 -k "HKLM\\Software\\CoreCodec\\CoreAVC Pro\\Serial" -v "0OKWX-E83B3-CORE-IQ0UW-3I3B7"

然后验证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.0Decoder supports the following YUV formats: YUY2 UYVY YV12 I420
Decoder is capable of YUV output (flags 0x2b)
Setting fmt
Starting
Initialization is complete


c. 配置mplayer和打补丁,在打补丁之前,一定要先./configure,要不然是打不上补丁的。
代码:
cd ~/mplayer
./configure --enable-gui --enable-freetype --codecsdir=/usr/lib/codecs --language=zh_CN

打补丁
代码:
patch -p0 < ../coreavc-for-linux/mplayer/dshowserver.patch

然后编译安装
代码:
make
sudo make install


最后还有一步
编辑~/.mplayer/中的codecs.conf文件。如果没有这个文件,就拷贝一个过去
代码:
cp etc/codecs.conf ~/.mplayer/
gedit ~/.mplayer/codecs.conf

把下面这一段拷贝到codecs.conf中,VIDEO CODECS部分的最前面。
代码:
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


最后,把从源里安装的mplayer改个名,保证以后调用的都是编译的mplayer。
代码:
sudo mv /usr/bin/mplayer /usr/bin/mplayer.apt

好,现在,大功告成。哪怕是Atom CPU,也能基本流畅地播放720P视频了。


备注:mplayer编译过程中还可能出错给/libavcodecs/libx264.c加个补丁就好了。如下:

mplayer.patch代码:

diff -ru ~/mplayer/libavcodec/libx264.c ~/mplayer/libavcodec/libx264.c
--- ~/mplayer/libavcodec/libx264.c   2008-10-06 21:04:25.000000000 -0400
+++ ~/mplayer/libavcodec/libx264.c   2008-10-16 15:14:54.945469559 -0400
@@ -162,7 +162,11 @@

x4->params.i_bframe = avctx->max_b_frames;
x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC;
+#if X264_BUILD > 62
x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
+#else
+    x4->params.b_bframe_adaptive = avctx->b_frame_strategy;
+#endif
x4->params.i_bframe_bias = avctx->bframebias;
x4->params.b_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID;
avctx->has_b_frames= avctx->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!avctx->max_b_frames;
@@ -227,6 +231,10 @@
x4->params.analyse.i_me_range = avctx->me_range;
x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;

+#if X264_BUILD < 65
+    x4->params.analyse.b_bidir_me = avctx->bidir_refine > 0;
+    x4->params.analyse.b_bframe_rdo = avctx->flags2 & CODEC_FLAG2_BRDO;
+#endif
x4->params.analyse.b_mixed_references =
avctx->flags2 & CODEC_FLAG2_MIXED_REFS;
x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA;
保存代码后执行 patch -p0 <  mplayer.patch
系统交流群:17264279
图书分享群:18246379
农牧乐园群:6925950

TOP

标记备用
向老大学习……we code our lives!

TOP

发新话题