Thursday, September 25, 2008

Compiling x264 with MP4 support on OS X

I've been wanting to futz around with the internals of a modern video codec, and since H.264 seems like a pretty happening codec, and the x264 project seems pretty awesome, I downloaded their source and tried compiling it on my Mac. I hit a few roadbumps, so here are instructions for anyone else who wants to compile x264 on OS X:


wget http://downloads.sourceforge.net/gpac/gpac-0.4.4.tar.gz
open gpac # lazy-man's untar
git clone git://git.videolan.org/x264.git x264
cd gpac
find . -name os_net.c | xargs perl -pi -e 's/u_long/unsigned long/g'
./configure
make lib
make install-lib

cd ../x264
./configure --enable-mp4-output
make


Then, to test that everything worked, run this:

wget notlime.com/2008/h264/foreman_part_qcif.yuv
./x264 -v -q 20 -o foreman.mp4 foreman_part_qcif.yuv 176x144
open foreman.mp4


If you don't have git installed, you can find a nightly tarball of the x264 source code at ftp://ftp.videolan.org/pub/videolan/x264/snapshots/. Hope this helps someone!

3 comments:

Unknown said...

The deep question -- what do you think and how do you feel about video codecs? Do you have a particular project in mind?

Graham said...

That's cool, what do you plan to do?

Compression methods and transformation methods go hand in hand.

Mark said...

I'd like to take two pieces of video and mix the key frames from one with the motion prediction of the other. A sort of separation of declaration and definition ;)