LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-17-2008, 12:42 AM   #1
H.264
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Rep: Reputation: 0
How do you compile MPlayer with H.264 Support?


I have been having trouble compiling MPlayer with H.264 support.

Do any of you know of a page with good instructions?
 
Old 02-17-2008, 12:55 AM   #2
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
This is a pretty good guide. It does not cover H.264/MPEG-4 AVC support, but it is probably a simple matter to add it.

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 all 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/sou...me-3.97.tar.gz
wget http://puzzle.dl.sourceforge.net/sou...-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 -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.

A good page on how to rip a DVD to an MPEG-4 avi file is:

<LINKS REMOVED FOR INAPPROPRIATE CONTENT>

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.

Last edited by jtshaw; 04-09-2008 at 06:25 AM. Reason: removed the usual links....
 
Old 02-17-2008, 12:58 AM   #3
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
I would imagine that you just need one more section, like:

./configure
make
make install

Where did you get the source code from?
 
Old 02-17-2008, 01:16 AM   #4
H.264
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Wow, that was quick.
I got the source code from ftp://ftp.videolan.org/pub/videolan/x264/snapshots/
I am using x264-snapshot-20080214-2245.tar.bz2
I will read your reply and try some things.
Thanks a lot.

Last edited by H.264; 02-17-2008 at 01:20 AM.
 
Old 02-17-2008, 03:40 PM   #5
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
I have never bothered with H.264 before as I didn't know much about it.

After reading up on it: http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC and elsewhere,

comments like: "As such, the codec started to show significant gains over then best open standard, MPEG-4 ASP" made it sound like something I want, so I also decided to have a shot at compiling it.

I downloaded the same version of x264 as you. After looking at

./configure --help

it is clear that you need the --enable-shared option as mplayer will need the shared libraries.

I figured the --enable-gtk option can't hurt.

./configure --enable-shared --enable-gtk

make gave the error message: make[1]: xgettext: Command not found

This is a fairly typical error message due to the age of my gettext version and can be fixed by the standard --disable-nls option. If English is your language then you can safely add this option. So I tried:

./configure --enable-shared --enable-gtk --disable-nls

You get the message:

Unknown option --disable-nls, ignored

However, it is not ignored and this configuration compiles.

Here is the full configuration report:

Code:
./configure --enable-shared --enable-gtk --disable-nls
Unknown option --disable-nls, ignored
No suitable assembler found.  x264 will be several times slower.
Please install 'yasm' to get MMX/SSE optimized code.
svn: This client is too old to work with working copy '.'; please get a newer Subversion client
Platform:   X86
System:     LINUX
avis input: no
mp4 output: no
pthread:    yes
gtk:        yes
debug:      no
gprof:      no
PIC:        no
shared:     yes
visualize:  no
Do I really need yasm? Do you know if x264 is fast enough not to bother?

I also wonder if the --enable-mp4-output option, which uses gpac, is useful? MPlayer is meant to be able to output the MP4 format anyway. Do you know how to get mplayer to output to MP4?

I tracked gpac to http://gpac.sourceforge.net/home_download.php

After running ldconfig, I was able to compile MPlayer (no configuration options).

How's the compilation going with you?

Do you know how to use x264? Do you know how to use MPlayer with x264?
 
Old 02-18-2008, 03:54 AM   #6
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
By the way, the --disable-nls does not work.

I miss-typed the command line as:

./configure --enable-shared --enable-gtkl --disable-nls

This caused GTK to be disabled, which gave me the idea that the --disable-nls option had worked.

Thus it compiled, but without GTK.

The moral is: if your version of gettext contains xgettext, then use the --enable-gtk option. Otherwise, upgrade gettext or just use

./configure --enable-shared
 
Old 02-18-2008, 05:29 PM   #7
H.264
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ComputerGreek View Post
Do you know how to use MPlayer with x264?
Thanks for your effort. I haven't had time to do anything yet, but to use mplayer to encode a DVD, you need something like

Code:
mencoder dvd://1 -oac mp3lame -lameopts br=96:cbr -ovc frameno -o frameno.avi
mencoder dvd://1 -oac copy -ovc x264 -x264encopts bitrate=2000:pass=1 -vf lavcdeint -o output.avi
mencoder dvd://1 -oac copy -ovc x264 -x264encopts bitrate=2000:pass=2 -vf lavcdeint -o output.avi
Quote:
Originally Posted by ComputerGreek View Post
Do I really need yasm? Do you know if x264 is fast enough not to bother?
If you have an older machine, yasm may not help at all.
If you have a new machine, then definitely use yasm.

Last edited by H.264; 02-18-2008 at 07:02 PM.
 
Old 02-19-2008, 04:46 PM   #8
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
Quote:
Originally Posted by H.264 View Post
If you have an older machine, yasm may not help at all.
If you have a new machine, then definitely use yasm.
Yeah, I had to move everything to a more powerful computer. The encode times were just too large (and yasm did absolutely nothing).

I tried various encoding options, with the latest being:

Code:
mencoder dvd://1 -dvd-device /dev/scd0 -oac mp3lame -lameopts br=96:abr -ovc frameno -o frameno.avi
mencoder dvd://1 -dvd-device /dev/scd0 -oac copy -ovc x264 -x264encopts bitrate=900:pass=1:turbo=1 \
-vf lavcdeint -zoom -o output.avi -aspect 16:9 -vf crop=1024:416:0:80
mencoder dvd://1 -dvd-device /dev/scd0 -oac copy -ovc x264 -x264encopts bitrate=900:pass=2 \
-vf lavcdeint -zoom -o output.avi -aspect 16:9 -vf crop=1024:416:0:80
This still produces a rather large file size. Quality is OK. It is also probably wrong as it apparently doesn't use B-frames.

Last edited by ComputerGreek; 02-19-2008 at 05:56 PM.
 
Old 02-20-2008, 05:19 PM   #9
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
Anyone know how to seek to a given frame?

Actually, I just thought of one way:

mplayer -ss $((27877/25)) movie.mp4

will get you to frame 27877 when the frame rate is 25 f/s.

Last edited by ComputerGreek; 02-20-2008 at 05:23 PM.
 
Old 02-21-2008, 05:38 AM   #10
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
x264 encoding with mplayer is faulty. The recorded and actual bitrates differ by a lot.

Strangely, the recorded bitrate is set to that requested at the time of encoding.

However, the bitrate used by the encoder is NOT that requested at the time of encoding.

So, the bitrate is deliberately set different from that requested.

The linux Saboteurs at work again.
 
Old 02-21-2008, 02:54 PM   #11
H.264
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ComputerGreek View Post
So, the bitrate is deliberately set different from that requested.
I'm up to speed now.

Funny that you should mention the problem with mplayer x264 bitrates, cause I have found a similar problem with mplayer and the AAC codec.

With -oac faac -faacopts br=xxx, it refuses to produce bitrates lower than 112 kbps.

It certainly seems you are correct about it being deliberate.
 
Old 02-21-2008, 08:01 PM   #12
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
Quote:
Originally Posted by H.264 View Post
It certainly seems you are correct about it being deliberate.
Yeah, there are hundreds of instances of "Linux" people sabotaging Linux software, in particular, video and music software.

Usually, they (indirectly) work for the RIAA, MPAA, etc.
 
Old 02-21-2008, 09:59 PM   #13
andrew.46
Senior Member
 
Registered: Oct 2007
Distribution: Slackware
Posts: 1,365

Rep: Reputation: 493Reputation: 493Reputation: 493Reputation: 493Reputation: 493
Hi,

Has anybody tried simply using the svn x264? It can be downloaded pretty simply as:

Code:
$ svn co svn://svn.videolan.org/x264/trunk x264
And thus easily updated with:

Code:
$ svn update
I have done a little work with movie encoding, all very amateurish I am afraid which might perhaps be interesting:

http://www.andrews-corner.org/matrix.html

There is a small section there with x264 and faac encoding, trust me it produces fantastic results!

Andrew
 
Old 02-22-2008, 06:12 AM   #14
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
I downloaded faac-1.26.tar.gz from http://www.audiocoding.com/faac.html

I was able to duplicate the behavior that you reported.

Hi Andrew, thanks for the link. You should check both x264 and faac for anomalous results when encoding at low bitrates.

And yes, the results I got when recording at medium bitrates where very good.

By the way, if you don't want stuffed up movie aspects, you have to state them directly on the command line.

Something like the -aspect 16:9 -vf crop=1024:416:0:80 options I mention above.

This gives you large images without needing to scale.

Also: The x264 source code from ftp://ftp.videolan.org/pub/videolan/x264/snapshots/ is packaged every day. So you don't need to use subversion, unless you cannot wait a day, or you simply want to.

Last edited by ComputerGreek; 02-22-2008 at 06:20 AM.
 
Old 02-22-2008, 05:39 PM   #15
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
Andrew, let me know if you update your page.
 
  


Reply

Tags
avc, avi, h264, lame, mencoder, mp4, mpeg4, mplayer, video, x264



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mplayer won't compile with alsa support bruno buys Debian 6 08-23-2009 12:35 PM
Trying to compile MPlayer with JACK support blazemonger Slackware 1 05-10-2006 08:14 PM
Multithreaded H.264 decoding ? spinner_0 Linux - Software 0 02-08-2006 10:56 AM
Cannot compile MPlayer 1.0pre7 with x264 support ginobili_mvp Linux - Software 3 12-04-2005 11:25 AM
compile mplayer with libcss support ddpicard Linux - Software 10 11-21-2002 01:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration