sesam.hu

Engineering Manager | Trail Runner | Stockholm, Sweden

Installing FFmpeg on OS X Mountain Lion

Wednesday, 5 September, 2012 - sesam

From time to time I need to do simple jobs with videos, such as a container change. I used to use mencoder for that back on linux and I still think that the versatility of a command line tool is unparalleled by any GUI solution. So I set out to get FFmpeg on my Mac.

There is a static build available from the FFmpeg website, but I decided to take a somewhat more complicated approach and compile it from source myself.

To do so, one first needs Xcode , available from the Mac App Store. The current versions, however, do not contain the command line tools needed. A separate package called Command Line Tools needs to be installed from either navigating to the Downloads for Apple Developers site from Xcode by Xcode > Open Developer Tool > More Developer Tools… or using the built-in package manager at Xcode > Preferences… on the Downloads tab.

Two packages need to be installed separately first: LAME for mp3 encoding (compulsory) and FAAC for AAC (optional). The tar.gz files can be unpacked by, for example:

tar -xzvf faac-1.28.tar

Then enter their respective directories and issue:

./configure
make
sudo make install

Finally, check out the latest source code of FFmpeg:

git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg

Compile it with LAME and FAAC enabled (the latter only if it’s installed). The --enable-nonfree switch is required by FAAC and I got an error unless I disabled Yasm.

./configure --enable-libmp3lame --enable-shared --enable-libfaac --enable-nonfree --disable-yasm
make
sudo make install

That’s all, FFmpeg is ready to use:

Daenerys:Downloads sesam$ ffmpeg
ffmpeg version N-44141-g9de7622 Copyright (c) 2000-2012 the FFmpeg developers
  built on Sep  4 2012 16:10:11 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  configuration: --enable-libmp3lame --enable-shared --enable-libfaac --enable-nonfree --disable-yasm
  libavutil      51. 70.100 / 51. 70.100
  libavcodec     54. 55.100 / 54. 55.100
  libavformat    54. 25.104 / 54. 25.104
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3. 15.103 /  3. 15.103
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'