Easy Install FFmpeg in Linux
How to Install FFmpeg on Linux Server
FFmpeg is so important if you are planning to run a video website with streaming with conversion of video files to different video formats. This tutorial is intended for Centos/Redhat versions of Linux where any novice user can install ffmpeg without compiling the source which is a more traditional way of installing the FFmpeg software on linux servers. In this tutorial i will show you the easy way to install ffmpeg and ffmpeg-php (php extension) with just yum rather than compiling ffmpeg from source files.
yum install ffmpeg
If you get command not found, then you will need to add few lines in the yum repository for dag installation.
Create a file named dag.repo in /etc/yum.repos.d with the following contents on it
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1
then
yum update
yum install ffmpeg
If everything is fine, then the installation should proceed smoothly. If not you will get something like warning GPG public key missing .
To fix rpmforge GPG key warning:
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
For more information refer to this faq
If you get missing dependency error like shown below, in the middle of ffmpeg installation
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package ffmpeg
Error: Missing Dependency: libtheora.so.0(libtheora.so.1.0) is needed by package ffmpeg
Error: Missing Dependency: rtld(GNU_HASH) is needed by package ffmpeg
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package imlib2
Error: Missing Dependency: rtld(GNU_HASH) is needed by package a52dec
Error: Missing Dependency: rtld(GNU_HASH) is needed by package imlib2
Error: Missing Dependency: rtld(GNU_HASH) is needed by package gsm
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package x264
Error: Missing Dependency: rtld(GNU_HASH) is needed by package xvidcore
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package lame
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package a52dec
Error: Missing Dependency: rtld(GNU_HASH) is needed by package faad2
Error: Missing Dependency: rtld(GNU_HASH) is needed by package x264
Error: Missing Dependency: rtld(GNU_HASH) is needed by package lame
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package xvidcore
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package faac
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package faad2
Error: Missing Dependency: libgif.so.4 is needed by package imlib2
Error: Missing Dependency: rtld(GNU_HASH) is needed by package faac
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package gsm
Error: Missing Dependency: libpng12.so.0(PNG12_0) is needed by package imlib2
Error: Missing Dependency: rtld(GNU_HASH) is needed by package libmp4v2
Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package libmp4v2
then most commonly you have GLIB 2.3 installed instead of GLIB 2.4 version. To check the current GLIB version installed on your server. just use
yum list glib*
and it should list all the packages whether installed or not. Try to see whether Glibc 2.4 installed, if not you will need to upgrade your Centos to latest version of 5.
To check the ffmpeg working:
Finally, check the ffmpeg whether it is working or not.
> ffmpeg
> ffmpeg -formats
> ffmpeg --help
// This lists path of mpeg, its modules and other path information
> ffmpeg -i Input.file Output.file
To check what audi/video formats are supported
ffmpeg -formats > ffmpeg-format.txt
Open the ffmpeg-formats.txt to see the ooutput
D means decode
E means encode
V means video
A means audio
T = Truncated
Install FFMPEG-PHP Extension
FFmpeg-php is a very good extension and wrapper for PHP which can pull useful information about video through API interface. Inorder to install it you will need to download the source file and then compile and install extension in your server. You can download the source tarball : http://ffmpeg-php.sourceforge.net/
wget /path/to/this/file/ffmpeg-php-0.5.2.1.tbz2
tar -xjf ffmpeg-0.5.2.1.tbz2
phpize
./configure
make
make install
Common Errors
If you get command not found error for phpize, then you will need to do yum install php-devel
If you get an error like shared libraries not found problem and the program halts in the middle, then you must specify the ffmpeg installed path explicitly to the ./configure.
“configure: error: ffmpeg shared libraries not found. Make sure ffmpeg is compiled as shared libraries using the –enable-shared option”
To Fix:
1. First find out the ffmpeg path with ffmpeg –help command. The prefix default path should be like /usr/local/cpffmpeg
2. Configure the FFmpeg-php with –with-ffmpeg option
./configure --with-ffmpeg=/usr/local/cpffmpeg
That should resolve the problem!
Editing PHP.INI
Once you have done that without any problems then you will see the php extension file /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so and you will need mention that extension in php.ini file
nano /usr/local/lib/php.ini
Put the below two lines at the end of the php.ini file
[ffmpeg]
extension=ffmpeg.so
Then restart the server service httpd restart
To check whether ffmpeg enabled with php, point your browser to test.php file. It should show the confirmation
If any case the ffmpeg does not show in the phpinfo() test make sure that php.ini path to ffmpeg.so is correct. Still the problem occurs, the reason could be you might be using older versions of ffmpeg-php which is buggy. Just download the latest version of ffmpeg-php source then compile it.
Useful Links
FFmpeg (http://ffmpeg.mplayerhq.hu)
Mplayer + Mencoder (http://www.mplayerhq.hu/design7/dload.html)
Flv2tool (http://inlet-media.de/flvtool2)
Libogg + Libvorbis (http://www.xiph.org/downloads)
LAME MP3 Encoder (http://lame.sourceforge.net)
Install FFmpeg from Compiling Source (Tutorial Link)
Nice FFmpeg Installation Tutorial (click here)
Important Audio Codecs (http://www.mplayerhq.hu/DOCS/HTML/en/audio-codecs.html)
Common Errors & Fixes while Installing FFmpeg (click here)
- May 4th

















Thank you very much for the post…FFMpeg on CENTOS is quite difficult and this was the best tutorial Ive found…
FFMpeg-php is now giving me errors…
In file included from /usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.c:40:
/usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.h:72: error: syntax error before “AVFormatContext”
/usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.h:72: warning: no semicolon at end of struct or union
/usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.h:77: error: syntax error before ‘}’ token
/usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.c:56:5: missing binary operator before token “(”
/usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.c:65: error: storage class specified for parameter `ffmpeg_movie_class_entry_ptr’
/usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.c:68: error: storage class specified for parameter `le_ffmpeg_movie’
/usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.c:69: error: storage class specified for parameter `le_ffmpeg_pmovie’
/usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.c:74: error: parameter `ffmpeg_movie_class_methods’ is initialized
/usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.c:77: warning: implicit declaration of function `PHP_ME’
/usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.c:77: error: `ffmpeg_movie’ undeclared (first use in this function)
/usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.c:77: error: (Each undeclared identifier is reported only once
/usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.c:77: error: for each function it appears in.)
/usr/local/src/ffmpeg-php-0.5.2.1/ffmpeg_movie.c:77: confused by earlier errors, bailing out
make: *** [ffmpeg_movie.lo] Error
Any ideas?
i know this is really old, but in this blog entry - baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag is an invalid path. When itry to include thisin the dag.repo file, i get an error. please can u help me out on this
j37h3r, did you install ffmpeg header files. It is needed for ffmpeg-php. use yum install ffmpeg-devel
smoizs, change only mirror, not the base one.