Sunday, November 20, 2011

Compile mplayer on OS X

Finally, success. My tears of frustration did not short out my kkkkkkeyboard and I ca finally type ut thi simple howto (well, simle for me ayway).

So why compile mplayer? There's a relatively recent binary for Tiger and up available here inside an application wrapper that you can extract if you want to use it from the command line. It's from September 2009, recent enough for pretty much anything now, but it's almost 2012 and 2014 or 2015 are just around the corner, and by then it'll be six years old. So what if nobody steps up and provides a distributable binary for Tiger or PowerPC users? What if it's 2015 and users clinging to Classic and using TenFourFox 147 need an updated binary? Well, you're gonna have to roll your own and here are the basic steps to do it.

First, in order to compile anything, you need to install Xcode. In fact, for this compile specifically, you'll need SVN and Git, too. Specific instructions about this are in two posts back here. Also, you'll need to install Make 3.82 available here.

If you haven't added /usr/local/bin to your path, do it now by editing or creating ~/.bash_profile and adding the line:

. ~/.bashrc
(don't forget both dots).

Then edit or create the file ~/.bashrc with the line:

PATH="$PATH:/usr/local/bin"

With this you can call anything installed in /usr/local/bin simply by typing the application name in the command line.

Onto compiling:

On the surface it's just a simple process of downloading the source, running ./configure, make, and sudo make install, but I came across a few hurdles that I'll show you how to get over.

First, create a new folder to download the source into, set that folder to the current directory, and then download the source with these three commands:

mkdir ~/Development

cd ~/Development

svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer (on one line)

Then you want to run the configuration script like this:

cd mplayer

./configure --enable-menu --with-freetype-config=/usr/X11R6/bin/freetype-config (on one line, the two arguments are for OSD support and require X11 to be installed)

At this point I got a message I wasn't prepared for: No FFmpeg checkout, press enter to download one with git or CTRL+C to abort

When I didn't have Git installed, that was a problem. But after I installed Git and reran the script, I simply pressed enter and continued on. At this point you may get a longer error message that ends with:

git pull failed, (re)move ffmpeg/mp_auto_pull to disable pulling

The solution is to remove "mp_auto_pull" from ~/Development/mplayer/ffmpeg. Then when the ./configure script ends, run make. But there's a bug here. Make 3.80 won't work. You'll get an error, make: *** virtual memory exhausted. Stop. You have to upgrade to Make 3.82.

After installing 3.82, you'll notice the default Make is still 3.80 in /usr/bin. Since I didn't know how to make the new version the default and wasn't sure of the implications of mixing an updated Make with other dev tools, I just invoked it by typing its full path. So after the ./configure script completes, type:

/usr/local/bin/make (this will take awhile)

Then at the conclusion, run:

sudo /usr/local/bin/make install

And that's it! You should have a working binary. To get Truetype subtitles working, you can copy any fontname.ttf file from your /Library/Fonts directory to ~/.mplayer/subfont.ttf like:

cp /Library/Fonts/fontname.ttf ~/.mplayer/subfont.ttf (one line)

The file in your ~/.mplayer folder must be called subfont.ttf.

When I first started this whole mess, I couldn't get it to compile with OSD support. I tried using Macports to install some of the dependencies as described here, and man what a nightmare. Finally I went back to look for a simple explanation and found the ./configure arguments for OSD support here.

And with that I'm gonna watch a movie.

No comments:

Post a Comment