HOWTO: Compiling the latest FFmpeg & x264 on CentOS 4
August 06, 2008
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 herefor instructions.
- Update the install
- (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 & 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.gztar xzvf faad2-2.6.1.tar.gzcd faad2autoreconf -vif./configuremakemake install
- Compile & Install GPAC
cd ~wget http://downloads.sourceforge.net/gpac/gpac-0.4.4.tar.gztar -xzvf gpac-0.4.4.tar.gzcd gpac./configuremakemake installmake 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.confldconfig
- Compile & Install x264
cd ~git clone git://git.videolan.org/x264.gitcd x264./configure --enable-pthread --enable-mp4-output --enable-sharedmakemake install
- Update the links to the shared libs…again
- Install ffmpeg
cd ~svn export svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpegcd 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-libmp3lamemakemake 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.confldconfig
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