HOWTO: Compiling the latest FFmpeg & x264 on CentOS 4
Wednesday, August 6th, 2008Intoduction
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
- Ensure that you have the rpmforge repo’s added to yum. See here for instructions.
- Update the install
yum update
- (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 - Install the necessary build tools
yum install gcc gcc-c++ automake autoconf libtool yasm git subversion
- 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
- 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
- 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.
- Update the links to the shared libs
echo '/usr/local/lib/' > /etc/ld.so.conf.d/gapc-1386.conf ldconfig
- 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
- Update the links to the shared libs…again
ldconfig
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
- 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…
- All done.