View Single Post
Old 2006-01-24, 18:13   Link #1
anime_layer
Senior Member
*Graphic Designer
 
 
Join Date: Feb 2003
Location: Zürich, Switzerland
Send a message via ICQ to anime_layer
[HOW-TO] Compile MPlayer on OSX

I recently managed to compile MPlayer and MEncoder on OSX after several unsuccessful attempts in Linux. It's actually not that hard and so I thought I'd write up a little tutorial.

Why bother, you might ask. Well.. 1st it's makes you feel better, gives you some expirience with *nix and you'll get a faster MPlayer (x264 playback was 20% faster compared to the last official binary release of MplayerOSX).

What we gonna need:
• The Developer Tools. Grab the latest version off Apple Developer Connection (free registration - recommended)
• X11 or FreeType
• MPlayer source
• ffmpeg source
• XviD source (optional)
• lame source (optional)
• x264 source (optional)

I've put the optional stuff for the MEncoder (XviD, lame, x264) at the bottom but those have to be installed first if you want them.

1. Little set-up

Everything here will be done with the Terminal. You can find it in Applications > Utilites > Terminal.app

You gonna need X11 from Apple for the FreeType library (if you don't already have it or want to obtain it directly). X11 can be found on the OSX installer DVD.

First we gonna make a folder for all the sources to be put in. When you open a new Terminal you start in your home folder (/Users/name/) and we create a folder called "Development" right there and open it:
Code:
mkdir Development
cd Development
2. Get sources

We gonna get the latest CVS version (newest of the new - might be buggy). You can get the latest tarball or release if you prefer. Getting the latest ffmpeg source will bring you the most performance improvements.

To get the MPlayer source we create a folder for it and fetch it from the CVS.
You first have to log in and when you get asked for a password, just hit enter. After that you get back to the command line and can enter the second cvs command.
Code:
mkdir mplayer-src
cd mplayer-src
Code:
cvs -d:pserver:anonymous@mplayerhq.hu:/cvsroot/mplayer login
cvs -z3 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/mplayer co -P main
Same thing for the ffmpeg source which is actually on the same server:
Code:
cd ..
mkdir ffmpeg-src
cd ffmpeg-src
cvs -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg login
cvs -z3 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg co -P ffmpeg
Then we need to copy the things we need from the ffmpeg source over to the MPlayer source (no trailing slash in the first path or you will copy the files and not the folder):
Code:
cp -R ffmpeg/libavcodec ../mplayer-src/main/
cp -R ffmpeg/libavutils ../mplayer-src/main/
cp -R ffmpeg/libavformat ../mplayer-src/main
That's it! Now either install the optional software or proceed directly to compiling MPlayer.

3. Compiling MPlayer

Now we're ready to start compiling. First we change to the MPlayer source directory and start configure with those options:
--with-freetype-config=/usr/X11R6/bin/freetype-config (The FreeType library from X11 - read above)
--disable-gl (GL doesn't play nice while compiling. Might compile fine but you don't need this anyway)
--disable-x11
(dito)
But first we specify where pkgconfig is:
Code:
export PKG_CONFIG_PATH="/usr/X11R6/lib/pkgconfig/"
./configure --with-freetype-config=/usr/X11R6/bin/freetype-config --disable-gl --disable-x11
You should see a lot of options being auto-set (XviD, Lame and x264 should be recognized automatically - spot them in the list or check the configure.log) and finish with telling you that it succeeded configuring MPlayer.
Now we can start compiling which will take a while:
Code:
make
After compiling stops (hopefully without errors), you can install MPlayer or use/move it where you want.
Code:
sudo make install
(Enter your password - you need to be an administrator)

4. Finishing up

If you now type "mplayer" in the console there's a good chance that you'll get a "-bash: mplayer: command not found".
MPlayer has been installed into /usr/local/bin/ but that folder is not in bash's (Terminal's) default path and so it can't find it. You can either copy mplayer and mencoder from /usr/local/bin/ to /usr/bin/ or add /usr/local/bin/ to your PATH - which is a good idea if you plan to do stuff like this in the future.
To do this, we need to create a .bash_profile and a .bashrc file in your home folder (/User/name/ or abbreviated as ~):
Code:
cd ~
nano .bash_profile
Your terminal window will now be used by the nano text editor. Type in following line:
Code:
. ~/.bashrc
Exit with ctrl-x -> Y -> Enter
Then create the .bashrc file:
Code:
nano .bashrc
And enter following line:
Code:
PATH="$PATH:/usr/local/bin"
Again, exit with ctrl-x, y and enter.
When you open a new Terminal window, mplayer should now be recognized as a command. You can play a movie by typing "mplayer " and then dragging your movie into the terminal window.


2b: Optional stuff

In order to use XviD, Lame and x264 to encode within MEncoder, you need to install them first. You can skip them if you don't need them and you don't have to install all of them.

XviD:
Create a folder, fetch the source, compile:
Code:
cd ~/Development
mkdir xvid-src
cd xvid-src
Code:
cvs -d:pserver:anonymous@cvs.xvid.org:/xvid   login
cvs -d:pserver:anonymous@cvs.xvid.org:/xvid   co xvidcore
cd xvidcore/build/generic
./bootstrap.sh
./configure
make
sudo make install
On OSX MPlayer doesn't like the xvidcore library so we need to fix it (seems to work):
Code:
cd /usr/local/lib/
sudo ranlib libxvidcore.a
Lame:
Create a folder, fetch source, compile:
Code:
cd ~/Development
mkdir lame-src
cd lame-src
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/lame login     
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/lame co -P lame
cd lame
./configure
make
sudo make install
x264
Create a folder, fetch source, compile. x264 uses subversion instead of CVS which isn't installed on OSX by default so got the latest tarball from:
ftp://ftp.videolan.org/pub/videolan/x264/snapshots/
and copy it to ~/Development/x264-src

Code:
cd ~/Development
cd x264-src
tar -zjf x264-snapshot-2006XXXX-XXXX.tar.bz2
cd x264-snapshot-2006XXXX-XXXX
./configure
make
sudo make install
__________________
MPlayer OSX Extended (en) | nimmermehr (de) | sttz (de) | last.fm
Life is a game whose first rule is: This is not a game, this is dead serious.

Last edited by anime_layer; 2006-02-11 at 16:08.
anime_layer is offline