Free Web Space | BlueHost Review  


Homepage: http://linuxhelp.150m.com/


Compiling MPlayer.


MPlayer allows you to play DVDs, watch video clips, and even listen to MP3s. MPlayer is probably the best movie player there is. Certainly, the best I know of.

An earlier version of this page (for mplayer-1.0pre8) can be found here.

If you follow the instructions given here you will be able to watch almost all video formats, watch DVD's, watch streaming video, rip DVD's to MPEG-4 avi files, and preform many other useful video functions. MPlayer plays just about everything. And, if you so wish, you can add a graphical user interface.

To get a list of the formats supported, see this page. Here are some:

Video codecs: 3ivx, Cinepak, DivX, DV, H.263, H.264/MPEG-4 AVC, HuffYUV, Indeo, MJPEG, MPEG-1, MPEG-2, MPEG-4, RealVideo, Sorenson, Theora, WMV, XviD

Audio codecs: AAC, AC3, ALAC, AMR, FLAC, MP2, MP3, RealAudio, Shorten, Speex, Vorbis, WMA

Container formats: 3gp, AVI, ASF, FLV, Matroska, MOV, MP4, NUT, Ogg, OGM, RealMedia

So, lets get on with the compilation:

Make sure that you have the following programs and packages installed.

gcc libgcc glibc glibc-devel glib2 glib2-devel gcc-c++ libstdc++ libstdc++-devel

Make sure you are the root user, then make a directory in which to work:

 mkdir /mplayer

Download the following files, saving them in the directory /mplayer/

MPlayer-1.0rc2.tar.bz2
all-20071007.tar.bz2
font-arial-iso-8859-1.tar.bz2 from www.mplayerhq.hu
live555-latest.tar.gz from www.live555.com (currently live.2007.12.27.tar.gz)
lame-3.97.tar.gz from lame.sourceforge.net
twolame-0.3.10.tar.gz from sourceforge.net/projects/twolame
libsndfile-1.0.17.tar.gz from www.mega-nerd.com/libsndfile

 cd /mplayer/

The sourceforge links were once deliberately sabotaged (by HTTP redirect) so you can try going direct, with:

wget http://puzzle.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
wget http://puzzle.dl.sourceforge.net/sourceforge/twolame/twolame-0.3.10.tar.gz

The following command unpackages the archives:

 for a in *.tar.*; do tar -xf $a; done

Even though most compilations install into /usr/local/, some Red Hat derived distributions do not include /usr/local/lib in the default library loader path. This is just another example of Red Hat making it a little harder for you to compile your own programs. To fix this problem, add /usr/local/lib to the file /etc/ld.so.conf, with the command:

 echo "/usr/local/lib" >> /etc/ld.so.conf

Setting the LD_LIBRARY_PATH no longer seems to be necessary, but it doesn't hurt:

 export LD_LIBRARY_PATH=/usr/local/lib/

So, lets proceed:

 rm -fr /usr/local/lib/{live,win32}  (remove some old stuff)

 cd /mplayer/live
 ./genMakefiles linux
 make  (nothing happens if the C++ libraries are not installed)
 cd /mplayer; mv /mplayer/live /usr/local/lib/

 mv /mplayer/all-20071007 /usr/local/lib/win32

The latest version of the codecs does not come with DivXc32f.dll, so if you have a need for it, you will have to copy it from a previous edition. If you do not have a need for it, just ignore this step:

 cp DivXc32f.dll /usr/local/lib/win32

The default configurations, of all the programs below, install their libraries in /usr/local/lib/.

 cd /mplayer/libsndfile-1.0.17
 ./configure
 make
 make install

If you have any queries about the configuration, use the following command:

 ./configure --help  (viewing the help)

Now, do the same thing with the other packages:

 cd /mplayer/lame-3.97
 ./configure --with-fileio=sndfile

This will use the libsndfile libraries. You get read/write ability to these file formats:

RAW
Microsoft WAV
SGI/Apple AIFF/AIFC
Sun/DEC/NeXT AU/SND
Paris Audio File PAF
Commodore Amiga IFF/SVX
Sphere Nist WAV
IRCAM SF
Creative VOC
Sound forge W64
GNU Octave 2.0 MAT4 & 2.1 MAT5
Portable Voice Format PVF
Fasttracker 2 XI
HMM Tool Kit HTK
Apple CAF


See the local documentation accompanying the source code.

Drop the option, if you wish to use lame's io routines. You get RAW & WAV.

There are problems getting lame's mp3 frame analyzer, mp3x, working. Click here, to see how.

 make
 make install

 cd /mplayer/twolame-0.3.10
 ./configure
 make
 make install

Usually ldconfig is run to update newly added libraries, but the install scripts for lame and twolame don't bother, so you have to do it:

 ldconfig

 cd /mplayer/MPlayer-1.0rc2
 ./configure

./configure, provides a summary of the optional drivers that it will enable, eg,

Enabled optional drivers:
  Input: ftp network tv-v4l2 tv-v4l tv live555 mpdvdkit2 vcd dvb
  Codecs: qtx libavcodec real xanim dshow/dmo win32 faad2(internal) libmpeg2 liba52 mp3lib tremor(internal) libmad twolame
  Audio output: alsa jack esd arts oss nas mpegpes(dvb)
  Video output: xvidix cvidix md5sum pnm jpeg png mpegpes(dvb) aa opengl dga xv x11 xover tga
  Audio filters: ladspa
Disabled optional drivers:
  Input: vstream tv-bsdbt848 cdda dvdread smb
  Codecs: opendivx x264 xvid libdv amr_wb amr_nb faac musepack libdts libtheora speex toolame liblzo gif
  Audio output: sgi sun openal polyp dxr2 dsound win32 sdl
  Video output: winvidix bl zr zr2 dxr3 dxr2 directx sdl vesa gif89a fbdev svga caca ggi xmga mga xvmc directfb tdfx_vid s3fb tdfxfb 3dfx
  Audio filters:

Check to see if you have all the drivers you want. If you want one of the "disabled optional drivers" then you will have to download and install additional software, or, as in the case of the Audio/Video output option sdl, you need to install the sdl development package included with your distribution.

You should also take a look at the configure.log:

 less configure.log

Check that ./configure found the lame and twolame libraries.

 make
 make install

Now install the global font for sub-titles:

 cp /mplayer/font-arial-iso-8859-1/font-arial-18-iso-8859-1/* /usr/local/share/mplayer/font/

You can also install a local font preference. Exit the root account, to your usual user account, then execute the following commands:

 mkdir -p ~/.mplayer/font/
 cp /mplayer/font-arial-iso-8859-1/font-arial-18-iso-8859-1/* ~/.mplayer/font/

The above process, has given you two binaries, one called mplayer, to play movies/videos, and the other, called mencoder, to encode movies/videos. For more information concerning the playing and recording of video, see the local documentation and FAQ accompanying the source code.

You play videos/movies with commands like:

 mplayer name.wmv  (watch the video with filename name.wmv)
 mplayer WishYouWereHere.mp3  (listen to Pink Floyd)
 mplayer mms://address.of.site/movie.wmv  (watch a "Microsoft Media Server" stream)
 mplayer rtsp://address.of.site/movie.wmv  (watch a RTSP stream)
 mplayer -identify name.wmv  (identify aspects of the movie name.wmv)
 mplayer -dumpstream rtsp://site/movie.rm  (download movie.rm to file stream.dump)
 mplayer dvd://1 -dvd-device /dev/hdc  (watch a DVD starting at chapter one)

The -dvd-device /dev/hdc in the last command, is not necessary, if your DVD has been properly setup. The last command also assumes the movie starts at chapter one. If it starts at chapter 3, you will need dvd://3, etc. RTSP stands for "Real Time Streaming Protocol."

If I get time, I will write a tutorial, or two, on how to use mencoder.
Here, is a good page on how to rip a DVD to an MPEG-4 avi file (local copy here).
In the mean time, here are a few simple examples:

1) mencoder mms://address.of.site/movie.wmv -ovc copy -oac copy -o output.avi
2) mencoder rtsp://address.of.site/movie.wmv -ovc copy -oac copy -o output.avi
3) mencoder movie.wmv -ovc lavc -lavcopts vcodec=msmpeg4:vbitrate=750:vhq -oac mp3lame -o output.avi
4) mencoder dvd://1 -aid 129 -oac mp3lame -lameopts br=48:cbr:vol=6 -ovc frameno -o frameno.avi
5) mencoder movie.wmv -ovc copy -ofps 24000/1001 -oac mp3lame -of mpeg -o output.mpg

The above commands do the following (in order):

1) save an MMS video stream to the file output.avi (AVI is the default format).
2) save an RTSP video stream to the file output.avi.
3) encode WMV video as MPEG4 video with MP3 audio.
4) rip the German audio stream from a DVD and save it as an "MP3 video" labeled by frame number.
5) change the WMV file from AVI format to MPEG format with MP3 audio.

Sometimes, in order to convert an audio file to an MP3, you must first convert it to some huge WAV file. This WAV file can be many gigabytes in size. If you are short on filespace, you can create a named pipe to pass on the WAV file, as it is created. This way, you never need to write the whole file. In the following example, mplayer will write the WAV file to the pipe and lame will read it from the pipe and convert it to an MP3.

First, grab a file that you wish to convert to an MP3.

 mplayer -dumpstream -dumpfile music.ra rtsp://site/music.ra

Without the -dumpfile tag, the download would be saved as stream.dump.
Create a named pipe called pipe.wav

 mkfifo pipe.wav

Now execute the following command. It will hang, as it is waiting for the data to flow through the pipe.

 lame pipe.wav music.mp3  (add your favorite lame options (including ID3 tags))

In a different terminal, execute the following command, to get the data flowing.

 mplayer -ao pcm:file=pipe.wav music.ra

You can also execute the last two commands in reversed order, but it doesn't illustrate what is going on as clearly. This whole idea of named pipes, is also very useful in scripts.

So, we are able to convert music.ra, to music.mp3, even when space is limited.


 AS ALWAYS, USE AT OWN RISK.