How to Install FFMpeg on CentOS

By | July 20, 2012

If you would like to deal with multimedia content streaming, you should add ffmpeg support to your Centos installation. The installation is similar on other Redhat-based linux distributions.

First of all, let’s start with the list of packages you should have before installing ffmpeg:

yum install SDL-devel a52dec a52dec-devel alsa-lib-devel faac faac-devel faad2 faad2-devel
yum install libdc1394 libdc1394-devel
yum install yasm nasm
yum install amrnb-devel amrwb-devel
yum install freetype-devel giflib gsm gsm-devel imlib2 imlib2-devel lame lame-devel libICE-devel libSM-devel libX11-devel
yum install ncurses-devel
yum install libtheora libtheora-devel
yum install subversion
yum install glibc gcc gcc-c++ autoconf automake libtool
yum install libid3tag libogg-devel libvorbis-devel mesa-libGL-devel mesa-libGLU-devel xorg-x11-proto-devel xvidcore xvidcore-devel zlib-devel
yum install libXau-devel libXdmcp-devel libXext-devel libXrandr-devel libXrender-devel libXt-devel

If you are getting any errors, you should add an additional repository :

rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
yum -y update

Then repeat the lines with yum mentioned above.

Next we need to download codecs, that will be used. I suggest to download all codecs. Here is how:

wget http://www.mplayerhq.hu/MPlayer/releases/codecs/all-20110131.tar.bz2
bunzip2 all-20110131.tar.bz2; tar xvf all-20110131.tar
mkdir /usr/local/lib64/codecs/
mkdir /usr/local/lib/codecs/
cp all-20110131/* /usr/local/lib/codecs/
cp all-20110131/* /usr/local/lib64/codecs/
chmod -R 755 /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib64/codecs/

Next step is to grab FFMpeg:

svn checkout -r 20525 svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

Now we need x264 library

wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20120719-2245.tar.bz2
bunzip2 x264-snapshot-20120719-2245.tar.bz2; tar xvf x264-snapshot-20120719-2245.tar

Next step is to erase x264 if it is installed – we will compile one from sources:

yum erase x264*
cd x264
./configure –enable-shared –prefix=/usr
make
make install

Then we need to compile FFmpeg itself:

cd ffmpeg
./configure –enable-gpl –enable-nonfree –enable-postproc –enable-libfaad –enable-avfilter –enable-pthreads
–enable-libxvid –enable-libx264 –enable-libmp3lame –enable-libfaac –disable-ffserver –disable-ffplay
–enable-libtheora –enable-libvorbis –disable-ffplay –enable-shared –enable-avfilter-lavf
make
make install

I have listed the most common configure parameters above. If you need any specific requirements – you should add them to configure line. You need to add –arch=x86_64 to configure line if you are on a 64-bit system.

Next step is to add a line to config:

vi /etc/ld.so.conf

add this line:

/usr/local/lib

Activate the shared libraries

ldconfig

That’s it. Your installation should be completed and you should be able to run FFmpeg.