Building ffmpeg on Ubuntu Linux

Recently decided to take advantage of some ffmpeg new latest features on an Ubuntu system. Here’s what had to be done to get it ready.

First, install all the necessary Ubuntu packages.

aptitude install git-core nasm 
  libswscale-dev libavcodec-dev libavformat-dev 
  libvorbis-dev libtheora-dev 
  liblame-dev liblame0  libgsm1-dev libgsm-tools libgsm1  
  libfaad2-dev libfaac-dev libgpac-dev  
  libxvidcore4-dev liba52-0.7.4 liba52-0.7.4-dev 

Then, make a location for the source and export the newest stuff!

cd /usr/src
git clone git:// 
cd x264
./configure --prefix=/usr --enable-pthread --enable-shared 
  --enable-mp4-output --enable-pic
make install

mkdir /usr/src/ffmpeg-trunk
cd /usr/src
svn export svn:// ffmpeg-trunk
cd ffmpeg-trunk
./configure --enable-gpl --enable-shared --enable-swscale --enable-pthreads 
  --enable-libdc1394 --enable-libfaac --enable-libfaad --enable-libgsm 
  --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 
  --disable-debug --extra-version 'edoceo'

Now there is this custom ffmpeg stored in /usr/src/ffmpeg-trunk/. If it fails you’ll need to search for the necessary -dev package with apt-cache search libXXX

I choose to leave it here, notice I did not indicate to run make install. This means I have Ubuntu standard ffmpeg in the path, as the distribution expects it and the custom stuff stays out of the main system. Just have to remember the full path every time.

The ffmpeg that is built will not have some of it’s lib files installed in an expected location (because we left off the make install). So we’ll have to sym-link them into place

cd /usr/src/ffmpeg-trunk
ln -s libswscale/ ./
ln -s libavdevice/ ./
ln -s libavformat/ ./
ln -s libavcodec/ ./
ln -s libavutil/ ./

Then run this custom ffmpeg as follows

LD_LIBRARY_PATH="/usr/src/ffmpeg-trunk" /usr/src/ffmpeg-trunk/ffmpeg [options] [outfile]

Another option, common for us is to specify a new prefix, such as --prefix=/opt/ffmpeg-trunk then install there.