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

ZFS on OS X (10.5 Leopard)

ZFS has a (mostly) working port for OS X. There are some minor quirks associated with using it, and similar to the current Solaris releases it cannot be used as the root filesystem (yes, OpenSolaris can currently do this).

The page for this project is: http://zfs.macosforge.org/trac/wiki/

Some of the pitfalls I've encountered include (these are known issues):
  • Finder, and some relatively expanded directory names associate the name of certain folders at mountpoints with the root name of the pool, instead of the name of the actual folder at that mountpoint. Meaning, if your pool is named tank, and you mounted tank/Music to /Users/asherwin/Music, some programs such as iTunes that automatically attempt to use ~/Music will resolve the directory to ~/tank, or /Users/asherwin/tank. There is no workaround for this, and it means you can't do certain things (such as use a ZFS filesystem as a home dir... I've tried, and it just poses too many problems with this current limitation).
  • Issuing a scrub command results in a kernel panic.
  • The special .zfs/snapshot directory functionality is not yet ported, but snapshots still work (you can mount a snapshot temporarily to utilize it).
If you like to tinker, and can live with some minor inconveniences, this is a great technology to play with. I've been using it successfully for over a month with no problems, besides the known issues.