|
Homepage: webng.com/linuxhelp (Update June 4, 2009) Compiling And Using MPlayer & Mencoder 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.0rc2) 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. Some of the supported formats are: 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 libdvdnav and libdvdread are now in the mplayer source code. libdvdnav has been borrowed from the Ogle DVD player project. It is the code that allows point and click navigation through DVD menus. For unstated reasons (general sabotage?) this feature has been removed from the libdvdnav code and is not available for Mplayer. Apparently, what you can do, is write a .map file that will allow you to record/watch a pre-chosen path through the DVD. So, lets get on with the compilation: Make sure that you have the following programs and packages, or their equivalent, installed. gcc (C compiler) libgcc1 libglib2.0-0 libglib2.0-dev g++ (C++ compiler) libstdc++ libstdc++6-4.3-dev 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-export-snapshot.tar.bz2 from www.mplayerhq.hu font-arial-iso-8859-1.tar.bz2 from www.mplayerhq.hu live555-latest.tar.gz from www.live555.com (currently live.2009.04.20.tar.gz) lame-3.97.tar.gz from lame.sourceforge.net twolame-0.3.12.tar.gz from sourceforge.net/projects/twolame libsndfile-1.0.17.tar.gz from www.mega-nerd.com/libsndfile faac-1.26.tar.gz from www.audiocoding.com yasm-0.7.1 from www.tortall.net x264-snapshot-20090523-2245.tar.bz2 from videolan.org The sourceforge links were once deliberately sabotaged (by HTTP redirect) so try: wget http://puzzle.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz wget http://puzzle.dl.sourceforge.net/sourceforge/twolame/twolame-0.3.12.tar.gz You may also want the following binary codecs from www.mplayerhq.hu: all-20071007.tar.bz2 (32-bit compilation) essential-amd64-20061203.tar.bz2 & xanimdlls-20040626.tar.bz2 (AMD64 compilation) Information on installing the various binary codecs can be found in my last mplayer guide. This guide will enable you to create 32-bit code on a 32-bit machine or 64-bit code on a 64-bit machine. The instructions in either case are nearly the same. To create 32-bit code for an AMD64 machine, is a little more complicated. I may write up a guide for that at some later date. So, let's begin. Change to the work directory and unpackages the archives: cd /mplayer/ 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 (32-bit system) echo -e "/usr/local/lib\n/usr/local/lib64\n/usr/local/lib32" >> /etc/ld.so.conf (64-bit system) If you wish to see where all your libraries are, run (as root) the commands: ldconfig ldconfig -p | awk '{print $NF}' ldconfig updates the /etc/ld.so.cache file and ldconfig -p lists all libraries found in /etc/ld.so.cache. Mplayer can make use of a host of libraries. I list some of them: aa amrnb amrwb artsc asound audio audiofile bs2b bz2 caca cdda_interface cdda_paranoia cdio cdio_cdda cdio_paranoia cucul dca directfb dl dts dv enca esd expat faac fontconfig freetype ggi ggiwmh gif GL ive jack jpeg kstat lircc lirc_client lrmi lzo2 m mad mng mp3lame mpcdec ncurses nsl nut ogg openal png posix posix4 pthread pthreadGC2 SDL smbclient speex ssl theora twolame ungif vbe vga vstream-client winmm ws2_32 X11 x264 Xdpms Xext Xinerama Xss Xt Xv xvidcore Xxf86dga Xxf86vm z. Each missing library, means some missing feature of mplayer (which is often, no big deal). If you wish to see which libraries mplayer is using, try one of the following commands: objdump -p /usr/local/bin/mplayer | grep NEEDED ldd -v /usr/local/bin/mplayer The first command, lists all libraries directly called by mplayer. The second command, also lists the libraries called by the libraries, i.e., all libraries directly and indirectly called by mplayer. The program objdump can be found in the binary utilities package. Now add any binary codecs you wish to /usr/local/lib/win32 and remove any old live-media stuff; rm -fr /usr/local/lib/live (remove old stuff) Move the new codecs to where they can be found by MPlayer, Amarok, Xine, etc; mv /mplayer/all-20071007 /usr/local/lib/win32 (for 32-bit compilation only) mv /mplayer/{essential-amd64-20061203,xanimdlls-20040626} /usr/local/lib/win32 (AMD64) Most 64 bit code has not been written to make use of windows 32 bit dll's (it could easily be, but it hasn't been), however the Real-Media and xanim codecs work. DivXc32f.dll is missing from the latest codecs, so if you have a need for it, you will have to copy it from a previous edition. cp DivXc32f.dll /usr/local/lib/win32 (if you are doing 32-bit compilation & desire it) Now we setup streaming media support: cd /mplayer/live ./genMakefiles linux make (nothing happens if the C++ libraries are not installed) cd /mplayer; mv /mplayer/live /usr/local/lib/ Now we setup the FAAC (Free AAC Encoder). AAC is designed to be the successor of MP3. The FAAC project includes the AAC encoder which supports several MPEG-4 object types (LC, Main, LTP, HE AAC, PS) and file formats (ADTS AAC, raw AAC, MP4), multichannel and gapless encoding as well as MP4 metadata tags. cd /mplayer/faac ./bootstrap ./configure make make install bootstrap is a small script that runs the auto configuration programs. It does: aclocal -I . autoheader libtoolize --automake automake --add-missing autoconf If you have any queries about a programs configuration, you can use the command: ./configure --help to view the available configuration help. Everything, is installed by default, in /usr/local/. We add the libsndfile libraries, since they are useful to many people: cd /mplayer/libsndfile-1.0.17 ./configure make make install If you wish to encode your audio to MP3, then you need to compile lame. The MP3 code included with the mplayer source, only allows you to play MP3s, not encode them. We configure the MP3 encoder lame to use the libsndfile libraries: cd /mplayer/lame-3.97 ./configure --with-fileio=sndfile make make install This will enable you to read and write these file formats (as well as MP3): 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 Sound Designer II (SD2) Free Lossless Audio Codec (FLAC) Drop the option --with-fileio=sndfile, if you wish to use lame's io routines. You get RAW & WAV (and, of course, MP3). For more on this, see the libsndfile documentation accompanying the source code. If you wish to compile lame's mp3 frame analyzer, mp3x, click here, to see how. Now we setup MP2 support: cd /mplayer/twolame-0.3.12 ./configure make make install Now we setup x264 support. x264 is a free software library for encoding H.264 video streams. H.264 is also know as MPEG-4 Part 10, or MPEG-4 AVC (for Advanced Video Coding). For x264 support you need a version of yasm newer than 0.6.2. cd /mplayer/yasm-0.7.1 ./configure make make install cd /mplayer/x264-snapshot-20080709-2245 ./configure --enable-shared --enable-asm --disable-nls make make install If you wish to have support, for x264, in a language other than English, then you need to make sure you have the program xgettext, which is part of the gettext package. The most recent version of gettext at the time of writing, was: gettext-0.17.tar.gz from ftp.gnu.org/gnu/ Once you have gettext installed, you can drop the --disable-nls configure option and thus enable native language support (nls). Now, run ldconfig to inform your system of the newly added libraries: ldconfig cd /mplayer/mplayer-export-2009-05-24 ./configure ./configure, provides a summary of the optional drivers that it will enable, eg,
Check to see if you have all the drivers you want. If you want one of the "disabled optional drivers" then you will probably have to install another development package (or compile the relevant software to obtain the necessary header files and libraries). You should also take a look at the configure.log: less configure.log For example, check that ./configure found the lame (libmp3lame) and twolame (libtwolame) 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 -zoom (use software scaling) 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. |