Compiling FFMPEG on Ubuntu with AAC and libx264 support

Aurélien Malisart

November 10, 2014

Lately, I've been doing a lot of ffmpeg tasks for one of my patners in the music business. We are using that software to generate videos for Youtube.

The recommended sound settings for a Youtube upload is :

MPEG AAC Audio (mp4a) 48kHz

and the standard of the industry for WAV files is :

PCM 44.1 kHz 16 bits

So when generating our videos, we need to encode our PCM input stream to AAC.

ffmpeg ships with a built-in AAC codec but it does not work perfectly. So we decided to use libfdk-aac instead. That library isn't opensource so you have to build ffmpeg against it manually in order to use it. Yey, I love compiling and linking stuff :-/

I followed the official compilation guide for Ubuntu but I had some issues. That's why I wrote this article : I don't want to search for a solution a second time !

Install base packages

sudo apt-get update
sudo apt-get -y install autoconf automake build-essential libass-dev \
  libfreetype6-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool \
  libva-dev libvdpau-dev libvorbis-dev libx11-dev libxext-dev \
  libxfixes-dev pkg-config texi2html zlib1g-dev unzip

mkdir ~/ffmpeg_sources


cd ~/ffmpeg_sources
tar xzvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"
make install


cd ~/ffmpeg_sources
tar xjvf last_x264.tar.bz2
cd x264-snapshot*
PATH="$PATH:$HOME/bin" ./configure \
  --prefix="$HOME/ffmpeg_build" \
  --bindir="$HOME/bin" \
  --enable-static --disable-opencl
PATH="$PATH:$HOME/bin" make
make install


The official instructions say to download from But that version ain't compile with ffmpeg for me, for whatever fucking reason.

So I decided to use an older version.

cd ~/ffmpeg_sources
git clone
cd fdk-aac*
git checkout v0.1.3
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make install

The key point here is the checkout of the v0.1.3 tag.


sudo apt-get install nasm
cd ~/ffmpeg_sources
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="$HOME/ffmpeg_build" --enable-nasm --disable-shared
make install

ffmpeg himself

cd ~/ffmpeg_sources
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$PATH:$HOME/bin" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
  --prefix="$HOME/ffmpeg_build" \
  --extra-cflags="-I$HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
  --bindir="$HOME/bin" --enable-gpl --enable-libfdk-aac --enable-libfreetype \
  --enable-libmp3lame --enable-libx264 --enable-nonfree
PATH="$PATH:$HOME/bin" make
make install

Some verifications

ffmpeg -codecs | grep AAC
ffmpeg -codecs | grep libx264

A symlink for convenience

sudo ln -s /home/ubuntu/bin/ffmpeg /usr/local/bin/ffmpeg

Done !
Easy. OK. I spent hours to get here. I hope it will help someone else.

Vous voulez travailler avec moi ?

Je suis développeur et consultant sur des projets informatiques dans ma société, Phonoid. Avec mes amis, nous y développons des solutions sur mesure pour nos super clients. Nous travaillons également sur nos futurs produits.