Austen's Blog

moon indicating dark mode
sun indicating light mode

HOWTO: Compiling the latest FFmpeg & x264 on CentOS 4

August 06, 2008

Introduction

FFmpeg is a superb video processing tool used to encode and transcode video files. In this particular project I needed to build “youtube” style video upload which would transcode into FLV, specifically catering for video files from the Nokia N95.

I spent quite a long time messing about with the stock version of ffmpeg on CentOS 4/Ubuntu trying to make it work, but it turned out not to be new enough/have all the right support compiled in.

This howto was written because I couldn’t find anything that fitted the bill for CentOS/RHEL (And being a Ubuntu man, found it a pain to get it compiled and working under CentOS). It’s based on the excellent tutorial by FakeOutdoorsman over on the Ubuntu forums. So big thanks to them.

These instructions have been tested on a fresh minimal install of CentOS 4.6 running in a VirtualBox VM. ### Preparation

  1. Ensure that you have the rpmforge repo’s added to yum. See herefor instructions.
  2. Update the install
yum update
  1. (If you are not installing onto a fresh minimal install) Remove ffmpeg, x264 and faad2 to avoid confusion.
yum remove ffmpeg x264 faad2 faad2-devel
  1. Install the necessary build tools
yum install gcc gcc-c++ automake autoconf libtool yasm git subversion
  1. Install the necessary libraries
yum install zlib-devel libmad-devel libvorbis-devel libtheora-devel lame-devel faac-devel a52dec-devel xvidcore-devel freetype-devel

Compile supporting libraries

  1. Compile & Install faad2 (for some reason I couldn’t get it to compile against the standard rpm version)
cd ~
wget http://downloads.sourceforge.net/faac/faad2-2.6.1.tar.gz
tar xzvf faad2-2.6.1.tar.gz
cd faad2
autoreconf -vif
./configure
make
make install
  1. Compile & Install GPAC
cd ~
wget http://downloads.sourceforge.net/gpac/gpac-0.4.4.tar.gz
tar -xzvf gpac-0.4.4.tar.gz
cd gpac
./configure
make
make install
make install-lib

Note: if the compile fails with a osmozilla related error, please see here. I had to remove mozilla support to get it to compile.

  1. Update the links to the shared libs
echo '/usr/local/lib/' > /etc/ld.so.conf.d/gapc-1386.conf
ldconfig
  1. Compile & Install x264
cd ~
git clone git://git.videolan.org/x264.git
cd x264
./configure --enable-pthread --enable-mp4-output --enable-shared
make
make install
  1. Update the links to the shared libs…again
ldconfig

Install ffmpeg

  1. Install ffmpeg
cd ~
svn export svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
cd ffmpeg
./configure --prefix=/usr/local --disable-debug --enable-shared --enable-gpl --enable-nonfree --enable-postproc --enable-swscale --enable-pthreads --enable-x11grab --enable-liba52 --enable-libx264 --enable-libxvid --enable-libvorbis --enable-libfaac --enable-libfaad --enable-libmp3lame
make
make install
  1. If ffmpeg has problems finding shared libraries, set the LD_LIBRARY_PATH
echo 'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib; export LD_LIBRARY_PATH' >> /etc/ld.so.conf
ldconfig

I’m not convinced that this is the correct thing to do, or the correct way to do it…but it seems to work…

  1. All done

Additional resources

http://www.tuxmachines.org/node/17063