(updated September 26, 2011)
FFmpeg (http://www.ffmpeg.org) is open source software to record, convert and stream audio and video in numerous formats.
The FFmpeg package requires the following external libraries, which are to be downloaded separately:
A successful FFmpeg build yields the following components:
Installation steps
1) First, download and install Xcode 3.2.1 (Snow Leopard) or Xcode 4.1 (Lion) development environment from Apple (https://developer.apple.com/xcode/). Because all sources for FFmpeg are written in C, the gcc compiler that comes with Xcode must be available in your Terminal shell, the command:
$ gcc --version
should print something like:
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5646) Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2) Download the latest LAME sources from http://sourceforge.net/projects/lame/files/
Unpack, configure, build, and install:
$ tar zxvf lame-398-2.tar.gz $ cd lame-398-2 $ ./configure $ make $ sudo make install
3) Download the latest sources of both FAAC and FAAD2 from http://sourceforge.net/projects/faac/files/
Unpack, configure, build, and install them both:
$ tar zxvf faac-1.28.tar.gz $ cd faac-1.28 $ ./configure $ make $ sudo make install $ $ tar zxvf faad2-2.7.tar.gz $ cd faad2-2.7 $ ./configure $ make $ sudo make install
4) Download the stable source code of SDL at http://www.libsdl.org/download-1.2.php
Then, generate configuration script, configure, build, and install:
$ cd SDL-1.2.14 $ ./autogen.sh $ ./configure --disable-assembly $ make $ sudo make install
5). Finally, get the latest sources from the FFmpeg project, configure, build, and install:
$ svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg $ cd ffmpeg $ ./configure --enable-libmp3lame --enable-libfaac --enable-libfaad --enable-gpl --enable-nonfree --enable-shared --disable-mmx --arch=x86_64 --cpu=core2 $ make $ sudo make install
If all goes well, the libraries will be installed in /usr/local/lib, and the executables ffmpeg, ffserver and ffplay in /usr/local/bin
Enjoy FFmpeg!
Optional installs
This article would not be complete without optional tools and codecs you may install. They are suited for people who are willing to experiment with compiling and installing stuff. I will keep adding items to this section after I have successfully implemented them myself.
First, we’ll install some extra tools that are required for some of the compiles, or will make your installations easier.
FLVtool
You may have noticed that Flash Video (.flv) files produced by FFmpeg may not show their running time correctly in a media player. FLVtool can insert meta data (e.g. running length) into .flv files. For more information, see http://rubyforge.org/projects/flvtool2/
Because Snow Leopard and Lion both have RubyGems (a Ruby package manager) pre-installed, flvtool2 can be easily obtained:
$ sudo gem install flvtool2
NASM and Yasm
Snow Leopard comes with an old version of NASM (The Netwide Assembler). Both Snow Leopard and Lion have no Yasm (Yet Another Assembler) installed. Therefore, get the latest stable release of NASM at http://www.nasm.us/pub/nasm/releasebuilds/ and of Yasm at http://www.tortall.net/projects/yasm/releases/, install both assemblers:
$ tar zxvf nasm-2.0.7.tar.bz2 $ ./configure $ make $ sudo make install $ $ tar zxvf yasm-0.8.0.tar.gz $ ./configure $ make $ sudo make install
Git
Both Subversion (svn) and CVS are pre-installed on Snow Leopard, but you may also want the other popular version control system, Git. To install Git on Snow Leopard (under Lion it is already present in your developer environment) follow the instructions at http://www.crainbandy.com/how-to/how-to-install-git-on-mac-os-x-leopard-snow-leopard
H.264
x264 is a free software library for encoding video streams into the H.264/MPEG-4 AVC format.
Yasm (installed earlier) is required to compile several assembly language routines present in the x264 code.
To obtain the x264 sources, either download the daily snapshot from http://download.videolan.org/pub/videolan/x264/snapshots/, or use Git:
$ git clone git://git.videolan.org/x264.git $ cd x264
Take care that the version of x264 >= 0.78. Then, configure, build and install the x264 library with:
$ ./configure $ make $ sudo make install
To rebuild FFmpeg to include H.264 support, add these two directives to the configure command:
--enable-libx264 --enable-static
Optional other formats
Usage examples