Compiling FFmpeg on Ubuntu

Supported OS: Ubuntu 12.10 (Quantal Quetzal), Ubuntu 12.04 (Precise Pangolin), and Ubuntu 11.10 (Oneiric Ocelot)Supported external libraries: libfaac, libmp3lame, libopencore-amrnb, libopencore-amrwb, libtheora, libvorbis, libvpx, libx264, avresample, libfdk-aac etc.

Compiling FFmpeg on a New Ubuntu Box
sudo apt-get updatesudo apt-get install build-essential autoconf pkg-config libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libgpac-dev libvorbis-dev libtool zlib1g-dev texi2html yasmThe dependent libraries can be installed as follows,sudo apt-get build-dep ffmpegsudo apt-get build-dep x264sudo apt-get build-dep libvpxThe FFmpeg compilation on Ubuntu starts with the installation of x264 (H.264 encoder)Download the latest x264 code from the git repo,

cd /home/user/code

git clone –depth 1 git://git.videolan.org/x264

cd x264

./configure –enable-shared

make

sudo checkinstall –pkgname=x264 –pkgversion=”3:$(./version.sh | awk -F’[" ]‘ ‘/POINT/{print $4″+git”$5}’)” –backup=no –deldoc=yes –fstrans=no –default

Next, install libvpx support for ffmpeg,

cd /home/user/code

git clone –depth 1 http://git.chromium.org/webm/libvpx.git

cd libvpx

./configure

make

‍sudo checkinstall –pkgname=libvpx –pkgversion=”1:$(date +%Y%m%d%H%M)-git” –backup=no –deldoc=yes –fstrans=no –default

Once this is done, we can go ahead & install AAC audio encoder (fdk-aac)support for FFmpeg,

cd /home/user/code

git clone –depth 1 git://github.com/mstorsjo/fdk-aac.git

cd fdk-aac

autoreconf -fiv

./configure –disable-shared

make

sudo checkinstall –pkgname=fdk-aac –pkgversion=”$(date +%Y%m%d%H%M)-git” –backup=no -deldoc=yes –fstrans=no –default

Since we are done with the supported libraries installation, we can compile FFmpeg,

cd /home/user/code

git clone –depth 1 git://source.ffmpeg.org/ffmpeg

cd ffmpeg

./configure –enable-gpl –enable-libfaac –enable-libmp3lame –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libtheora –enable-libvorbis –enable-libvpx –enable-libx264 –enable-nonfree –enable-version3 –enable-x11grab –enable-avresample –enable-libfdk-aac

Note: skip –enable-x11grab on Ubuntu Servers

make

sudo checkinstall –pkgname=ffmpeg –pkgversion=”7:$(date +%Y%m%d%H%M)-git” –backup=no –deldoc=yes –fstrans=no –default

Compiling qt-faststart

make tools/qt-faststart

sudo checkinstall –pkgname=qt-faststart –pkgversion=”$(date +%Y%m%d%H%M)-git” –backup=no –deldoc=yes –fstrans=no –default install -Dm755 tools/qt-faststart  /usr/local/bin/qt-faststart

Updating FFmpeg (on a machine where ffmpeg & all other libraries are installed)

sudo apt-get update

Now, start with x264,

cd /home/user/code/x264

make distclean

make clean

git pull

Once you obtain the new code, update the x264 as follows,

./configure –enable-shared

make ( if the make is giving any error, run the following commands,
make uninstall
make distclean
make clean
./configure –enable-shared)

sudo checkinstall –pkgname=x264 –pkgversion=”3:$(./version.sh | awk -F’[" ]‘ ‘/POINT/{print $4″+git”$5}’)” –backup=no –deldoc=yes –fstrans=no –default

Now lets update libvpx,

cd /home/user/code/libvpx

make distclean

make clean

git pull

./configure

make

‍sudo checkinstall –pkgname=libvpx –pkgversion=”1:$(date +%Y%m%d%H%M)-git” –backup=no –deldoc=yes –fstrans=no –default

Next, update the fdk-aac,

cd /home/user/code/fdk-aac

make distclean

make clean

git pull

autoreconf -fiv

./configure –disable-shared

make

sudo checkinstall –pkgname=fdk-aac –pkgversion=”$(date +%Y%m%d%H%M)-git” –backup=no -deldoc=yes –fstrans=no –default

Finally, update ffmpeg

cd /home/user/code/ffmpeg/

make distclean

make clean

git pull

./configure –enable-gpl –enable-libfaac –enable-libmp3lame –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libtheora –enable-libvorbis –enable-libvpx –enable-libx264 –enable-nonfree –enable-version3 –enable-x11grab –enable-avresample –enable-libfdk-aac

make

sudo checkinstall –pkgname=ffmpeg –pkgversion=”7:$(date +%Y%m%d%H%M)-git” –backup=no –deldoc=yes –fstrans=no –default

Update the qt-faststart,

make tools/qt-faststart

sudo checkinstall –pkgname=qt-faststart –pkgversion=”$(date +%Y%m%d%H%M)-git” –backup=no –deldoc=yes –fstrans=no –default install -Dm755 tools/qt-faststart  /usr/local/bin/qt-faststart

Thats it….    :)

Troubleshooting

Compiling FFmpeg on Ubuntu can give some errors. Some of the general errors & solutions are given below.

1) If the ‘make’ command on ffmpeg shows any error related to ‘libx264.so’, just uninstall libx264-dev package as follows,

sudo apt-get remove libx264-dev

Now the ‘make’ commad will execute successfully.

2) If the command ‘ffmpeg -v’ shows any error after completing the compilation process, just run the following command,

sudo ldconfig

Now, try running the command ‘ffmpeg -v’ . It will show you the appropriate version.