How to compile ffmpeg on a Raspberry Pi (with x264, mp3, and aac encoding)

Note : Using a Raspberry Pi 2B this install takes around one hour to complete

Update your repository

cd ~
sudo apt-get update

Install the required dependencies

sudo apt-get install pkg-config autoconf automake libtool yasm

Install x264 and mp3

sudo apt-get install libx264-dev
sudo apt-get install libmp3lame-dev

Download the ffmpeg and aac source code

git clone git:// ffmpeg
git clone ffmpeg/fdk-aac

Compile aac

cd /home/pi/ffmpeg/fdk-aac
./configure --enable-shared --enable-static
sudo make -j4
sudo make install
sudo ldconfig

Compile ffmpeg

cd /home/pi/ffmpeg
./configure --enable-libx264 --enable-gpl --enable-libmp3lame --enable-libfdk-aac --enable-nonfree
sudo make -j4
sudo make install

Test the ffmpeg installation

ffmpeg -version

PiEncoder – encode audio and video on a Raspberry Pi