Tuesday, September 2, 2008

Compile MPlayer on OS X (10.5 Leopard)

Building the trunk of the MPlayer subversion code on OS X turned out to be a bit of a chore for me, while in the end the process is actually quite simple.

I needed to build the trunk, because of a side-project; it required the ability to get the DVD title (movie name) from MPlayer, which currently did not ever write to any output streams.


Luckily, shortly after consulting the MPlayer IRC channel #mplayer on irc.freenode.net, and then the MPlayer Users mailing list, a nice committer on the project put in a small code change and committed it to the trunk for me as revision 27497.


The rest of the procedure is fairly straightforward, which basically breaks down to:


Install required and optional third party libraries. I used MacPorts, as it simplified acquisition, compilation and installation of the libraries. To use MacPorts for this process, download and install it from here, and install the following libraries:

  • freetype required
    sudo port install freetype
  • libdvdcss required
    sudo port install libdvdcss
  • libpng optional
    sudo port install libdvdcss
  • jpeg optional
    sudo port install jpeg
  • XviD optional
    sudo port install xvid
  • x264 optional
    sudo port install x264

Once you have all of the prerequisite software that you want to be compiled into MPlayer, get the MPlayer source from their public subversion (change last argument to where you want the source to reside on your computer):

svn checkout svn://svn.mplayerhq.hu/mplayer/trunk /path/to/local/mplayer

Now all you need to do it configure and make mplayer. Since the software installed by MacPorts is located in /opt/local, the configure command for mplayer will not autodetect the new libraries. Open a terminal in the mplayer directory that you checked out the source to, and use the following command:


./configure --with-freetype-config=/opt/local/bin/freetype-config --with-extralibdir=/opt/local/lib --with-extraincdir=/opt/local/include:/opt/local/include/libpng12:/opt/local/include/freetype2:/opt/local/include/fontconfig:/opt/local/include/dvdcss:/usr/local/include

The --with-extraincdir and --with-extralibdir options point to the software installed with MacPorts. Once configure has completed, issue the following command:


make

Once it has finished compiling, you should be left with a nifty mplayer executable file in the current directory!


You should be able to mix and match optional libraries for your needs, which can help you minimize the size of the mplayer executable depending on the targeted use. Look at the output of the configure command for additional libraries that you could possibly include.


Enjoy

No comments: