View Single Post
Old 2006-01-24, 18:13   Link #1
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 >

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:
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.
mkdir mplayer-src
cd mplayer-src
cvs login
cvs -z3 co -P main
Same thing for the ffmpeg source which is actually on the same server:
cd ..
mkdir ffmpeg-src
cd ffmpeg-src
cvs login
cvs -z3 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):
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)
But first we specify where pkgconfig is:
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:
After compiling stops (hopefully without errors), you can install MPlayer or use/move it where you want.
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 ~):
cd ~
nano .bash_profile
Your terminal window will now be used by the nano text editor. Type in following line:
. ~/.bashrc
Exit with ctrl-x -> Y -> Enter
Then create the .bashrc file:
nano .bashrc
And enter following line:
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.

Create a folder, fetch the source, compile:
cd ~/Development
mkdir xvid-src
cd xvid-src
cvs   login
cvs   co xvidcore
cd xvidcore/build/generic
sudo make install
On OSX MPlayer doesn't like the xvidcore library so we need to fix it (seems to work):
cd /usr/local/lib/
sudo ranlib libxvidcore.a
Create a folder, fetch source, compile:
cd ~/Development
mkdir lame-src
cd lame-src
cvs login     
cvs -z3 co -P lame
cd lame
sudo make install
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:
and copy it to ~/Development/x264-src

cd ~/Development
cd x264-src
tar -zjf x264-snapshot-2006XXXX-XXXX.tar.bz2
cd x264-snapshot-2006XXXX-XXXX
sudo make install
MPlayer OSX Extended (en) | nimmermehr (de) | sttz (de) |
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