FFmpegFFmpeg (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:

  • LAME (Lame Aint an MP3 Encoder), a high quality MPEG Audio Layer III (MP3) encoder
  • FAAC/FAAD2 (Freeware Advanced Audio Coder and Decoder 2), an implementation of the AAC audio compression format.
  • SDL (Simple DirectMedia Layer), is a multimedia library that provides access to graphics, sound, and input devices via OpenGL, and the 2D video framebuffer.

A successful FFmpeg build yields the following components:

  • FFmpeg libraries, the most important being libavcodec that contains all the FFmpeg audio/video encoders and decoders.
  • ffmpeg, a command line tool to convert one video file format to another.
  • ffserver, an HTTP an RTSP multimedia streaming server.
  • ffplay, a simple media player based on SDL and on the FFmpeg libraries.

Installation steps

1) First, download and install the latest Xcode 3.2.1 development environment from Apple (http://developer.apple.com/technology/Xcode.html). Because all sources for FFmpeg are written in C, the gcc compiler that comes with Xcode must be available on the command line:

$ 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 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 FAAC and FAAD2 from http://sourceforge.net/projects/faac/files/
Unpack, configure, build, and install 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) Get the latest sources from the SDL project, generate configuration script, configure, build, and install:

$ svn checkout http://svn.libsdl.org/trunk/SDL
$ cd SDL
$ ./autogen.sh
$ ./configure
$ 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 compilations, 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 has RubyGems (a Ruby package manager) preinstalled, flvtool2 can be very easily installed:

$ sudo gem install flvtool2

NASM and Yasm

Snow Leopard comes with an old version of NASM (The Netwide Assembler) and with no Yasm (Yet Another Assembler) installed. 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 preinstalled on Snow Leopard, but you may also want the other popular version control system, Git.

To install Git 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 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, add –enable-libx264 to the configure command.

Optional Others

  • XviD format: libxvid, http://downloads.xvid.org/downloads/xvid_latest.tar.gz
  • Ogg format: libogg, http://downloads.xiph.org/releases/ogg/
  • Ogg Vorbis audio: libvorbis, http://downloads.xiph.org/releases/vorbis/ (needs Ogg)
  • AMR-NarrowBand audio: libamr-nb, http://www.penguin.cz/~utx/amr
  • AMR-WideBand audio: libamr-wb, http://www.penguin.cz/~utx/amr
  • Theora video: libtheora, svn co http://svn.xiph.org/trunk/theora theora (needs Ogg and Vorbis)
  • Speex audio: libspeex, git clone git://git.xiph.org/speex.git (needs Ogg)
  • FLAC audio: libflac, http://sourceforge.net/projects/flac/files/flac-src/
  • GSM audio: libgsm, http://user.cs.tu-berlin.de/~jutta/gsm/gsm-1.0.13.tar.gz
  • NUT format: libnut, svn co svn://svn.mplayerhq.hu/nut/src/trunk/ nut
  • Schroedinger video: libschroedinger, http://diracvideo.org/download/schroedinger/ (requires liboil, http://liboil.freedesktop.org/download/)

Comments are closed.