LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1299|回复: 4

从源码编绎mplayer 给菜鸟看的

[复制链接]
发表于 2003-9-9 21:23:32 | 显示全部楼层 |阅读模式
./configure可以针对你的系统优化了
文档的另一份更新放在
http://dato.minidns.net/ctb/inde ... p;postid=10&p=1
我使用的系统是turbolinux workstation 8
developworkstation,KDE-313-8,gcc 3.2.2
如果你使用的也是turbolinux workstation 8我建议全新安装时选择developworkstation或者升级到developworkstation。当然如果你有足够的时间和精力去解决依赖关系的话,那你可以选择安装minidevelopwortstation。不得不说明一下依赖关系是一个很烦人的东东。
./configure --enable-gui编绎安装GUI界面的mplayer时,需要libpng、lingpng-devel、gtk+、gtk+-devel。事实上我很快就找到并安装上了缺少的包,可是仍然在./configure时通不过。记住去安装zlib、zlib-devel这两个包,层层依赖真是麻烦。

这篇文章主要教你从源码编绎安装mplayer、mplayerplug-in( 让你可以在浏览器里播放支持的视频)、xmmsmplayer(在xmms里看罗)
软件下载
mplayer官方下载页面
http://www.mplayerhq.hu/homepage/design6/dload.html
建议将以下几部分下载回来
ftp://ftp1.mplayerhq.hu/MPlayer/releases
ftp://ftp1.mplayerhq.hu/MPlayer/Skin     
皮肤文件
ftp://ftp1.mplayerhq.hu/MPlayer/DOCS/Chinese
中文文档
http://live.com
live.2003.09.05.tar.gz 这个文件顺便浏览一下他们的网站
http://docs.real.com/docs/playerpatch/unix/rv9_libc6_i386_cs2.tgz
支持在线观看.rmvb格式的文件

关于GCC的问题请参照这篇,http://www.mplayerhq.hu/MPlayer/ ... developers.html#gcc
为了避免问题,比如使用gcc2.95.3编绎php的httpd2 modules而使用gcc3.2编绎httpd2导致php和httpd不能结合的问题,建议将编绎时统一使用gcc2.95.3版本。
针对turbolinux 8 workstation
shell>cd /usr/bin
shell>vdir gcc*
shell>ln -sf gcc-2.95.3 gcc
shell>gcc -v
如果想改回gcc2.96
shell>ln -sf gcc-2.96 gcc


首先我们编绎并安装live以让mplayer可以支持流媒体播放
shell>tar zvfx live.2003.09.05.tar.gz
shell>cd live
shell>./genMakefiles linux
shell>make
shell>rm -rf /usr/lib/live
shell>cp -r live /usr/lib
如果你将live拷贝到非以下默认目录"/usr/local/", "/usr/local/lib/", or "/usr/lib/".
编绎mplayer时记得加上--enable-live --with-livelibdir=<path>
很幸运我没有碰到任何安装错误。(失败我没成功让它可以支持播放RTSP流)
如果你碰到请查阅官方文档
http://live.com/liveMedia/#config-unix
2。编绎mplayer程序
ftp://ftp1.mplayerhq.hu/MPlayer/ ... 播放别的像real quicktime windows media格式的文件。
官方提供了一个All-in-one package extralite.tar.bz2
只需要这个包播放real quicktime windows media格式的媒体文件都没有任何问题,为了支持播放在线的RMVB格式,我们还需要那个REAL升级包rv9_libc6_i386_cs2.tgz
将extralite.tar.bz2和rv9_libc6_i36_cs.taz里的所有文件解包并将所有文件安装到/usr/local/lib/codecs目录下
shell>bunzip2 -d extralite.tar.bz2
shell>tar vfx extralite.tar
shell>tar zvfx rv9_libc6_i386_cs2.tgz
shell>cp rv9\codecs\* extralite
shell>rm -rf /usr/local/lib/codecs
shell>mv extralite /usr/local/lib/codecs
接着我们安装mplayer程序MPlayer-0.91.tar.bz2
shell>bunzip2 -d MPlayer-0.91.tar.bz2
shell>tar vfx MPlayer-0.91.tar
shell>cd MPlayer-0.91
shell>
./configure --with-win32libdir=/usr/local/lib/codecs --with-codecsdir==/usr/local/lib/codecs  --enable-win32 --enable-gui --with-reallibdir=/=/usr/local/lib/codecs  --enable-l
ive --with-livelibdir/usr/lib/live --enable-xmms --language=zh_CN
事实上在README和.configure --help提到
Unpack the codecs archives and put the contents in a directory where MPlayer
will find them. The default directory is /usr/local/lib/codecs/ (it used to be
/usr/local/lib/win32 in the past, this also works)
but you can change that to
something else by using the '--with-codecsdir=DIR' option when you run './configure'.
--disable-qtx          disable Quicktime codecs [autodetect]

所以只要你是将需要的东东安装于程序的默认搜索路径,就可以进一步简化了
./configure --enable-gui --enable-live --with-livelibdir/usr/lib/live --enable-xmms --language=zh_CN
make (如果是freebsd 使用gmake)
make install
cp etc/input.conf /usr/local/etc/mplayer/
安装字体文件
在fonts目录下随便选一个字体拷贝到/usr/local/share/mplayer/font目录下
shell>bunzip2 -d font-arial-iso-8859-1.tar.bz2
shell>tar vfx font-arial-iso-8859-1.tar
shel>cp  font-arial-iso-8859-1\font-arial-14-iso-8859-1\* /usr/local/share/mplayer/font/
安装皮肤文件
shell>bunzip2 -d default-1.7.tar.bz2
shell>tar vfx default-1.7.tar
shell>cp -r default //usr/local/share/mplayer/Skin
搞定,字符下用mplayer,x下用gmplayer
想在纯字符界面下播放的话使用
mplayer -vo vesa filename(gef2 Mx 440通过)
 楼主| 发表于 2003-9-9 21:24:16 | 显示全部楼层

接着该解决mplayerplug-in一个可以让你在mozilla里嵌入电影的东东

它的官方网址
http://mplayerplug-in.sourceforge.net/
http://sourceforge.net/projects/mplayerplug-in/
我没安装过mozilla,最新的0。90老让那只火鸟崩溃。如果你也碰到就去下载个0。80用用吧。这个东东不是很有用根本不能看VOD,有比没有好,另外KDE313下的Konqueror老是使用默认的播放器,改了mplayer也不行,请高手指教。
它的安装很简单的解包后
make
然后生成一个mplayerplug-in.so
cp mplayerplug-in.so /usr/lib/mozilla/plugins
测试的话可以去
http://www.apple.com/quicktime
 楼主| 发表于 2003-9-9 21:25:00 | 显示全部楼层

xmmsmplayer让你可以在xmms里调用mplayer播放窗口

官方主页
http://www.cse.iitb.ac.in/nandan/xmmsmplayer/
下载
http://sourceforge.net/projects/xmmsmplayer/
首先你得先安装xmms
shell>tar zvfx xmmsmplayer-0.4.tar.gz
shell>cd xmmsmplayer-0.4
shell>./configure
shell>make
shell>make install
在/usr/lib/xmms/input/libxmmsmplayer.so文件
看看效果
 楼主| 发表于 2003-9-9 21:25:48 | 显示全部楼层

附录 mplayer README

安装之前读一下包里的README说明信息是个好习惯,它会解决你的很多疑惑
Welcome to MPlayer, the Unix movie player. MPlayer can play most standard video
formats out of the box and almost all others with the help of external codecs.
MPlayer currently works best from the command line, but visual feedback for
many functions is available from its onscreen status display (OSD), which is
also used for displaying subtitles. MPlayer also has a GUI with skin support and
several unofficial alternative graphical frontends are available.

MEncoder is a command line video encoder for advanced users that can be built
from the MPlayer source tree. An unofficial graphical frontend exists but is
not included.


This document is for getting you started in a few minutes. It cannot answer all
of your questions. If you have problems, please read the documentation in
DOCS/documentation.html, which should help you solve most of your problems.
Also read the man page to learn how to use MPlayer.



Requirements:
- You need a working development environment that can compile programs.
  On popular Linux distributions, this means having the glibc development
  package(s) installed.
- To compile MPlayer with X11 support, you need to have the XFree86 development
  packages installed.
- For the GUI you need the libpng and GTK 1.2 development packages.



Before you start...
Unless you know what are you doing, consult DOCS/video.html to see which driver
to use with your video card to get the best quality and performance. Most cards
require special drivers not included with XFree86 to drive their 2-D video
acceleration features like YUV and scaling.

A quick and incomplete list of recommendations:
- ATI cards: Get the GATOS drivers for X11/Xv or use VIDIX.
- Matrox G200/G4x0/G550: Compile and use mga_vid for Linux, on BSD use VIDIX.
- 3dfx Voodoo3/Banshee: Get XFree86 4.2.0+ for Xv or use the tdfxfb driver.
- nVidia cards: Get the X11 driver from www.nvidia.com for Xv support.
- NeoMagic cards: Get an Xv capable driver from our homepage as described in
  DOCS/video.html.

Without accelerated video even an 800MHz P3 may be too slow to play DVDs.


______________________
STEP0: Getting MPlayer
~~~~~~~~~~~~~~~~~~~~~~

Official releases, prereleases and CVS snapshots, as well as fonts for the
OSD, codec packages and a number of different skins for the GUI are available
from the download section of our homepage at

  http://www.mplayerhq.hu/homepage/dload.html

A set of fonts is necessary for the OSD and subtitles, the GUI needs at least
one skin and codec packages add support for some more video and audio formats.
MPlayer does not come with any of these by default, you have to download and
install them separately. A wide range of codec packages can be downloaded at

  http://www.mplayerhq.hu/MPlayer/releases/codecs/


You can also get MPlayer via anonymous CVS. Issue the following commands to get
the latest sources:

  cvs -d:pserver:anonymous@mplayerhq.hu:/cvsroot/mplayer login
  cvs -z3 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/mplayer co main

When asked for a password, just hit enter. A directory named 'main' will be
created. You can later update your sources by saying

  cvs -z3 update -dPA

from within that directory.


___________________________________
STEP1: Installing FFmpeg libavcodec
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you are using an official (pre)release, skip this step, since official
releases include libavcodec. CVS sources and thus CVS snapshots do not include
libavcodec. To verify if you do have libavcodec or not, check if a subdirectory
named 'libavcodec' exists in the MPlayer source tree.

The FFmpeg project provides libavcodec, a very portable codec collection (among
the supported formats is MPEG4/DivX) with excellent quality and speed, that is
the preferred MPEG4/DivX codec of MPlayer. You have to get libavcodec directly
from the FFmpeg CVS server.

To get the FFmpeg sources, use the following commands in a suitable directory
outside the MPlayer source directory:

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ffmpeg login
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ffmpeg co ffmpeg/libavcodec

When asked for a password, you can just hit enter. A directory named 'ffmpeg'
with a subdirectory named 'libavcodec' inside will be created. Copy (symbolic
linking does NOT suffice) this subdirectory into the MPlayer source tree.


_______________________________
STEP2: Installing Binary Codecs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MPlayer and libavcodec have builtin support for the most common audio and video
formats, but some formats require external codecs. Examples include Real, Indeo
and QuickTime audio formats. Support for Windows Media formats except WMV9
exists but still has some bugs, your mileage may vary. This step is not
mandatory, but recommended for getting MPlayer to play a broader range of
formats. Please note that most codecs only work on Intel x86 compatible PCs.

Unpack the codecs archives and put the contents in a directory where MPlayer
will find them. The default directory is /usr/local/lib/codecs/ (it used to be
/usr/local/lib/win32 in the past, this also works) but you can change that to
something else by using the '--with-codecsdir=DIR' option when you run
'./configure'.



__________________________
STEP3: Configuring MPlayer
~~~~~~~~~~~~~~~~~~~~~~~~~~

MPlayer can be adapted to all kinds of needs and hardware environments. Run

  ./configure

to configure MPlayer with the default options. The codecs you installed above
should be autodetected. GUI support has to be enabled separately, run

  ./configure --enable-gui

if you want to use the GUI.


If something does not work as expected, try

  ./configure --help

to see the available options and select what you need.

The configure script prints a summary of enabled and disabled options. If you
have something installed that configure fails to detect, check the file
configure.log for errors and reasons for the failure. Repeat this step until
you are satisfied with the enabled feature set.


________________________
STEP4: Compiling MPlayer
~~~~~~~~~~~~~~~~~~~~~~~~

Now you can start the compilation by typing

  make

You can install MPlayer with

  make install

provided that you have write permission in the installation directory.

If all went well, you can run MPlayer by typing 'mplayer'. A help screen with a
summary of the most common options and keyboard shortcuts should be displayed.

If you get 'unable to load shared library' or similar errors, run
'ldd ./mplayer' to check which libraries fail and go back to STEP 3 to fix it.
Sometimes running 'ldconfig' is enough to fix the problem.


NOTE: If you run Debian you can configure, compile and build a proper Debian
.deb package with only one command:

  fakeroot debian/rules binary


____________________________________________
STEP5: Installing the onscreen display fonts
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Unpack the archive and choose one of the available font sizes. Then copy the
font files of the corresponding size into /usr/local/share/mplayer/font/ or
~/.mplayer/font/ (or whatever you set with './configure --datadir=DIR').


____________________________
STEP6: Installing a GUI skin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Unpack the archive and put the contents in /usr/local/share/mplayer/Skin/ or
~/.mplayer/Skin/. MPlayer will use the skin in the subdirectory named default
of /usr/local/share/mplayer/Skin/ or ~/.mplayer/Skin/ unless told otherwise via
the '-skin' switch. You should therefore rename your skin subdirectory or make
a suitable symbolic link.


__________________
STEP7: Let's play!
~~~~~~~~~~~~~~~~~~

That's it for the moment. To start playing movies, open a command line and try

  mplayer <moviefile>

or for the GUI

  gmplayer <moviefile>


gmplayer is a symbolic link to mplayer created by 'make install'.
Without <moviefile>, MPlayer will come up and you will be able to use the GUI
filepicker.

To play a VCD track or a DVD title, try:

  mplayer -vcd 2 -cdrom-device /dev/hdc
  mplayer -dvd 1 -alang en -slang hu -dvd-device /dev/hdd

See 'mplayer -help' and 'man mplayer' for further options.

'mplayer -vo help' will show you the available video output drivers. Experiment
with the '-vo' switch to see which one gives you the best performance.
If you get jerky playback or no sound, experiment with the '-ao' switch (see
'-ao help') to choose between different audio drivers. Note that jerky playback
is caused by buggy audio drivers or a slow processor and video card. With a
good audio and video driver combination, one can play DVDs and 720x576 DivX
files smoothly on a Celeron 366. Slower systems may need the '-framedrop'
option.

Questions you may have are probably answered in the rest of the documentation.
The places to start reading are the man page, DOCS/documentation.html and
DOCS/faq.html. If you find a bug, read DOCS/bugreports.html first!
发表于 2003-9-10 17:05:58 | 显示全部楼层

为了全面,补贴一篇。 :)

发信人: hooey (brook), 信区: Linux
标  题: MPlayer指南
发信站: BBS 水木清华站 (Tue Mar 19 14:41:58 2002)

以下内容主要来自MPlayer的DOCS,希望能对大家安装使用MPlayer有帮助。如果写的有错
请大家见谅。

MPlayer是基本上基于GPL协议的。但有些非GPL的代码所以不能用binary包发布。依据法
律,MPlayer不能够做成rpm包发布。所以大家一定要使用source来编译,当然不能用rpm
包发布还因为MPlayer在编译是针对机器的具体配置做了很多优化。所以在一台机器上编
译的MPlayer不一定能在另
外的机器上运行(不过他们正在研究实时监测cpu的代码,下个版本应该就可以了)。

MPlayer能播放的文件:

这恐怕是大家最关心的,MPlayer能播放大多数MPEG,VOB,AVI,VIVO,ASF/WMV,QT/MOV,FLI,
RM,NuppelVideo,yuv4mpeg,FILM,RoQ文件.可以看VCD,SVCD,DVD,3ivx和Divx。而且最新的
MPlayer还可以播放WMA的音乐文件。(总之就是差不多什么都能放)。我到现在只有一个
文件,就是葛莱美颁奖
晚会的那个avi看不了。听MPlayer的Mail
list说是因为那个avi的音频编码方式还没有公开源代码(虽然他们承诺要公开的)。此
外MPlayer还支持硬件MPEG解码,比如DVB和DXR3/Hollywood+(要另外下支持代码),支持

MPlayer的安装:

MPlayer的安装其实很简单,如果你不想要divx,DVD播放,也不想要DXR3和Hollywood的支
持,这两个我觉得非重点,最后再说。只要有两个包。

MPlayer的源代码包(MPlayer-********.tar.bz2)和win32解码器的包(win32codec.zip),
如果是CVS版本但希望支持divx只要到divx.com去下一个divx4linux装一下(release版本
有libavcodec速度更快所以不要,cvs版本里面没有,要自己去下),另外,大家最介意的
一点就是MPlayer不推荐
用redhat自带的gcc2.96编译,也不推荐用gcc3.x.x,最理想的是2.95.3和2.95.4。原因
是因为2.96不接受MMX和3DNOW的代码。当然也可以用--disabel-gcc-checking跳过。另外
egcs编译器因为没有测试。可能也要用这个参数。

现在检查一下,你有了MPlayer的包,win32解码器的包。divx4linux装了。gcc2.95.3/4
也有了。下面就可以安装了。

先把win32codec.zip解压缩到/usr/lib/win32下面,然后在编译MPlayer源码。否则就没
有avi的支持了编译源码没什么好说的,就是configure,make,make install,如果希望
有图形界面的话,在configure是加
--enable-gui,另外还要到mplayer的网页上去下一个skin,解压缩放在.mplayer/Skin下

make install结束之后安装就完成了。0.5的MPlayer还要把codecs.conf拷到.mplayer下
面,0.60版的可以自己完成

MPlayer的配置和运行:

编译完了之后只要运行mplayer最简单的方法就是 mplayer 文件名,(如果你用的是
NVidia的显卡,可以装驱动。那样可以直接运行,如果不装驱动。还有两种选择,下面会
说明)当然配置一下会更好:

如果要看字幕(vobsub除外),必须把字体安装到.mplayer/font下面,中文字体在172.8可
以找到,当然也可以自己作,不过好像有点复杂,具体可以看DOCS的内容还有172.8的中
文字体下面的说明

编辑.mplayer下面的config文件(不记得MPlayer安装时候是不是创建这个文件,如果没有
的话自己建吧),在里面可以添加

skin=newskin

newskin用你在MPlayer下的skin的名字代替,然后用gmplayer命令就可以看到图形界面,
除非你下的skin是default,否则不设这一项直接用gmplayer是会出错的。这时候要用

unicode=1

这是看中文字幕必备,看英文字幕也没有妨碍,所以写到config里面。

vaa_nodr=1

如果你用的CVS版本,或者我想将来可能也要用,这是禁止直接写屏的选项。在我的
Nvidia Vanta下面如果没有这一项,显示时间,字幕等等会很不清晰,以前的版本没有问
题。可以不要这个选项。

aop= list=extrastereo

这是使用立体声增强的插件的命令。效果就跟xmms里面的那个效果一样,默认参数是2.5
。可以自己设定。如果你有四声道的声卡,还可以用surround取代extrastereo,那是环
绕立体声。但如果你没有那种声卡用这个参数会无法发声。

另外还有一些不固定的参数,可以在运行mplayer/gmplayer是选用(他们都可以添加到
config下面,config下面的命令也可以变成参数)

-bps/-nobps

这是最重要的参数,这是两种图像和声音同步的方式。如果你播放avi(只有avi文件会有
问题)时如果发现声音图像不同步可以试试这两个选项。

-vo ***
-ao ***

这是设定音频和视频的输出的选项,正常情况下没有什么用,当如果你的机器是nvidia的
显卡有没有装驱动可以用 -vo
sdl,就可以播放视频文件了。就是装了驱动。也可以试试这个选项。sdl会自动用nvidia
的库而且显示效果比直接用x11好(拖动窗口是不会有蓝色出现,按f就可以全屏,c可以在
能用的分辨率中切换)或者还有 -vo dga 和 -vo sdl:dga 这是用dga(Direct Graphics
Access)显示,但这种方式需要root权限,而且只能全屏播放,所以不推荐。具体可以看
DOCS里的内容

此外如果你有svgalib,用-vo svga可以不进X看avi文件,当然由于没有显卡驱动,你的
cpu最好非常快(我的nvidia显卡不会配svgalib,所以也没有试过,不知道非常快是什么
概念),而且一定用全屏播放

-fm -vm -zoom

据说是全屏命令,我一直用图形界面和sdl,没有试过这个命令

-vcd
-dvd

放影碟时用的命令。我没有光驱,所以没有尝试过

-ss <timepos>

这是命令行下面设定从什么地方开始放的命令。timepos的格式就是多少秒或者hh:mm:ss
,当看vobsub的电影是有用。

-sub <file>

指定字幕文件,vobsub字幕无效,而且mplayer会自动搜索当前目录下面的同名文件作为
字幕。

-vobsub <name> -vobsubid <id>

这是看vobsub字幕的命令。目前只有cvs版本才有。name是字幕文件的位置+名字,不带
后缀。但是后缀名一定要是小写,否则不认(如果你愿意可以修改一下vobsub.c,做个贡
献),一定要.idx,.ifo,.sub三个文件都有。我一直没有明白windows下面的vobsub2.09
怎么能不要.ifo。所以如
果没有.ifo的话只能去找别的字幕了。id是设定播放的语言。好像没有必然规律。反正试
试看,从0到40,一般0不是英语就是汉语。很快就能找到中文字幕了。

播放中还有些常用的功能键

/,              降低音量
*,              提高音量
左右方向键,      前进或后退10s
上下方向键,      前进或后退1min
o,              调整字幕显示方式
f,              全屏(0.60版只有sdl有效,cvs版本全部有效)

还有很多别的功能键可以看DOCS

使用经验

1.播放媒体文件时候非常慢。
如果你没有oss或者alsa的话装一个试试。速度比内核的驱动会有明显的提高。或者用
-ao sdl试试,可能会有效果。如果确认不是声卡的问题,那就看看你的显卡设置。或者你
的机器实在太慢了(pII 400以上都应该可以)。

2.播放vobsub字幕的时候很慢,但如果不用字幕就正常
没有什么好办法,好像vobsub.c写的有点问题。具体我也不太明白。但我有个歪招,就是
改一下spudec.c,把ANTIALIASING_ALGORITHM的设定值改为0,总共可以设三个值:0,1
,2。是控制字幕的显示质量的。数字越大质量越高。不过我看0和1没有什么差别。如果
你的机器很牛应该没问题


3.播放rm文件
虽然DOCS里面说能够播放。当只是开放编码格式的rm文件,不幸的是现在大部分rm文件都
不是。大家还是再装一个realplay吧。

4.字幕显示在电影画面上
用sdl播放可以把字幕调整到画面下方,如果可能的话。

5.无法使用sdl
升级,redhat自带的sdl好像版本低了点。

后记
还有很多东西没有写,比如播放DVD和VCD。还有用mencoder转换媒体文件等等。这个东西
实在是功能强大。大家可以慢慢研究。另外,原来MPlayer的一个成员现在自己搞了一个
MPlayer XP,他自己说速度快400%。但MPlayer说并不会快。只会更smooth。大家可以试





--

※ 来源:·BBS 水木清华站 smth.org·[FROM: 166.111.174.157]
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表