Compile FFMPEG with non-standard libraries

FFMPEG is a great tool for doing anything programmatically with audio or video files, but the default installation contains only open standards, and is therefore utterly incapable of converting AAC files and other common standards. Time to build it ourselves!

Mac OS

The compilation guide is excellent, follow that one. On a preconfigured Mac with XCode, command line tools, and Homebrew, it boils down to this:

brew install automake fdk-aac git lame libass libtool libvorbis libvpx \
opus sdl shtool texi2html theora wget x264 x265 xvid nasm
git clone ffmpeg
cd ffmpeg
./configure  --prefix="$HOME/bin" --enable-gpl --enable-nonfree --enable-libass \
--enable-libfdk-aac --enable-libfreetype --enable-libmp3lame \
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 \
--enable-libx265 --enable-libopus --enable-libxvid
make install

Which builds with AAC, Mp3, Vorbis, x264 support and more, and installs it to the user’s folder.

Note: depending on the Mac OS version (I think?) the binaries might end up in $HOME/bin/bin, so if which ffmpeg doesn’t work, simply move them up one level.


This is how ffmpeg is installed on Jenkins, taken from this page. First, install all the necessary packages:

sudo apt-get update
sudo apt-get install \
	nasm \
	yasm \
	autoconf \
	automake \
	cmake \
	git-core \
	libass-dev \
	libfreetype6-dev \
	libtool \
	libopus-dev \
	libmp3lame-dev \
	libvorbis-dev \
	libx264-dev \
	libx265-dev \
	libnuma-dev \
	libvpx-dev \
	libfdk-aac-dev \
	pkg-config \
	texinfo \

Then download the code, build, and install:

mkdir -p ffmpeg_sources
mkdir ~/bin
cd ~/ffmpeg_sources
wget -O ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
./configure \
  --prefix="$HOME/ffmpeg_build" \
  --pkg-config-flags="--static" \
  --extra-cflags="-I$HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
  --extra-libs="-lpthread -lm" \
  --bindir="$HOME/bin" \
  --enable-gpl \
  --enable-libass \
  --enable-libfdk-aac \
  --enable-libfreetype \
  --enable-libmp3lame \
  --enable-libopus \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libx264 \
  --enable-libx265 \
PATH="$HOME/bin:$PATH" make && make install