当前位置:Linux教程 - Linux资讯 - 在Fedora中编译安装Mplayer的步骤

在Fedora中编译安装Mplayer的步骤

1. 下载到必要的软件包

* MPlayer的源代码,我用的是MPlayer-1.0pre7.tar.bz2。

* Patch的名字是MPlayer-1.0_pre7-gcc4-fix.patch,顾名思义MPlayer在Gcc-4.0的环境中编译,也就是Fc4t2升级后的Fc3中。使用了Gcc-4.0 的时候,必须要打这个Patch才能编译成功。

* 必要的解码器,也就是Essential-codecs,或者也可以下载All-codecs。

* 一些解码器是可选的,比如LIVE.COM还有lzo、libmad等等。

* 准备一个中文的TTF字体。不过这个大家都有,不用去别处找。

2. 环境介绍

也就是说,我们要在什么样的环境里使用MPlayer。

* 没有图形界面,机器上没有Gtk-1.2所以就不用图形界面了。

* 默认Locale为UTF-8编码。

3. 编译步骤

1) 准备Codecs

本来我以为不需要/usr/local/lib/codecs,但是后来发现会找不到Xanim Codecs,所以还是需要它。链接到/usr/lib/win32是因为可以与 xine-lib共享这些解码器。

[root@geeks ~]# tar jxf all-20050412.tar.bz2 [root@geeks ~]# mv all-20050412 /usr/local/lib/codecs [root@geeks ~]# ln -s /usr/local/lib/codecs /usr/lib/win32

2) 解压

[root@geeks ~]# tar jxf MPlayer-1.0pre7.tar.bz2 [root@geeks ~]# cd MPlayer-1.0pre7

3) 打补丁

当然,只有Gcc-4.0的时候才需要打补丁,并且这个补丁只适合这次的情况,也就是说,只对这个MPlayer-1.0pre7.tar.bz2有效果。注意啊,我们现在在源代码目录了。下面是执行结果,好多文件被打上了补丁。

[root@geeks MPlayer-1.0pre7]# patch -p1 < ../MPlayer-1.0_pre7-gcc4-fix.patch

patching file configure patching file liba52/imdct.c patching file libavcodec/avcodec.h patching file libavcodec/common.h patching file libavcodec/ libpostproc/postprocess_template.c patching file libmpdemux/frequencies.h patching file libvo/ aclib_template.c patching file mmx.h patching file postproc/swscale_template.c

4) 配置

根据我们上面提到的环境,没有Gtk-1.2 所以不用--enable-gui之类的参数。但是我们需要中文的提示,并且是在Locale为UTF-8的情况下使用,所以要这样配置。-- charset=utf8是在Pre7里面新增的。下面是命令和输出结果。编译时的输出很重要,从这个输出中我们可以看到XAnim 和RealPlayer的解码器是从/usr/local/lib/codecs自动探测到的。没有加入Menu 和Xmms的支持,也没有GUI,但是这正是我需要的,因为我的系统中没有Xmms这些过时的Gtk-1.2程序。

[root@geeks MPlayer-1.0pre7]# ./configure --language=zh_CN --charset=utf8

Detected operating system: Linux Detected host architecture: i386 Checking for cc version ... 4.0.0, ok ...... Checking for XAnim DLL ... yes (using /usr/local/lib/codecs) Checking for RealPlayer DLL ... yes (using /usr/local/lib/codecs) Checking for LIVE.COM Streaming Media libraries ... no ...... Checking for OSD menu ... no Checking for QTX codecs ... yes Checking for SuBTitles sorting ... yes Checking for XMMS inputplugin support ... no Checking for inet6 ... yes Checking for gethostbyname2 ... yes Checking for GUI ... no ...... Config files sUCcessfully generated by ./configure ! Install prefix: /usr/local Data Directory: /usr/local/share/MPlayer Config direct.: /usr/local/etc/MPlayer Byte order: little-endian Optimizing for: pentium4 mmx mmx2 sse sse2 mtrr Languages: Messages/GUI: zh_CN Manual pages: en Enabled optional drivers: Input: FTP network edl tv matroska mpdvdkit2 vcd smb Codecs: qtx xvid libavcodec real xanim dshow/dmo win32 faad2(internal) libmpeg2 liba52 mp3lib tremor(internal) gif Audio output: alsa esd oss sdl mpegpes(file) Video output: xvidix cvidix sdl vesa gif89a md5sum pnm jpeg png mpegpes(file) fbdev opengl dga xv x11 xover tga Audio filters: Disabled optional drivers: Input: vstream tv-v4l2 tv-v4l tv-bsdbt848 live.com cdda dvdread dvb Codecs: opendivx x264 libdv amr_wb amr_nb libdts libtheora toolame libmad liblzo Audio output: sgi sun jack polyp arts dxr2 nas dsound win32 macosx Video output: winvidix bl zr zr2 dxr3 dxr2 directx svga caca aa ggi xmga mga xvmc directfb tdfx_vid tdfxfb 3dfx quartz Audio filters: ladspa

5) 编译和安装

在配置之后,通常的步骤是编译和安装,也就是Make && Make Install。但是这个版本的源代码缺少我们需要的一个文件,必须加上它。这个文件的作用是指明原始消息的编码。在Help目录有很多消息文件,每种语言的消息文件都有一个对应的文件来表示编码,这也是Pre7新加进来的。

[root@geeks MPlayer-1.0pre7]# echo 'GB2312' > help/help_mp-zh_CN.h.charset

6) Make && Make Install

这一步可能会出现编译刚开始就立即失败的情况。这时不妨运行一下Make Distclean,将所有临时文件都清空。清空临时文件,也就意味着我们的第三步 "配置" 的结果全部清除掉了,也就是说我们需要重新运行第三步。当然,参数是完全一样的。第四步就不必重新运行了,因为文件只需要建立一次。最后,重新运行 Make && Make Install

7) 运行 MPlayer 查看输出的效果

[root@geeks MPlayer-1.0pre7]# MPlayer

MPlayer 1.0pre7-4.0.0 (C) 2000-2005 MPlayer Team CPU: Intel Pentium 4/Xeon/Celeron Foster (Family: 8, Stepping: 9) Detected cache-line size is 64 bytes CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1

针对有扩展指令集x86 CPU编译:MMX MMX2 SSE SSE2。

用法:MPlayer [options] [urlpath/]filename。

基本选项:(包括所有选项的详细列表参见Manpage!)。

-vo