Installing FFMPEG and FFMPEG-PHP

How to install ffmpeg, ffmpeg-PHP, Mplayer, Mencoder, flv2tool, LAME MP3 Encoder, and Libog from source
This article shows how to install ffmpeg, ffmpeg-PHP, Mplayer, Mencoder, flv2tool, LAME MP3 Encoder, and Libog from source. It should work on most systems, however may need some tweaking from system to sytem.
Update server and include sourceforge:
rpm -Uhv
yum update
Gogo /usr/local/src:
cd /usr/local/src
Download source tarballs:
—– Test 2 ———–
New: wget
Extract the tarballs:
tar zxvf lame-3.97.tar.gz
tar zxvf libogg-1.1.3.tar.gz
tar zxvf libvorbis-1.1.2.tar.gz
tar zxvf flvtool2_1.0.5_rc6.tgz
tar jxvf essential-20061022.tar.bz2
tar jxvf ffmpeg-php-0.5.0.tbz2
tar zxvf flvtool2_1.0.5_rc6.tgz
—– test 2 ——
tar jxvf ffmpeg-php-
Make a directory to store all the codecs:
mkdir /usr/local/lib/codecs/
Install all necessary packages:
Install “phpize”:
yum -y install php-devel
Install gcc, gcc-cpp, and gcc-c++:
yum install gcc gcc-cpp gcc-c++
yum install gcc gmake make libcpp libgcc libstdc++ gcc4 gcc4-c++ gcc4-gfortran
yum install subversion ruby ncurses-devel
yum list gstreamer*                 <=== not available
yum install gstreamer-ffmpeg            <=== not available
yum install gstreamer-plugins-bad
yum install gstreamer-plugins-bad-extras <=== not available
yum install gstreamer-plugins-base
yum install gstreamer-plugins-good
yum install gstreamer-plugins-pulse <=== not availab
yum install gstreamer-plugins-ugly
yum install gstreamer-python
yum install gstreamer-tools
svn checkout svn:// ffmpeg
svn checkout svn:// mplayer
cd /usr/local/src/mplayer
svn update
cd /usr/local/src
Copy codecs for mplayer:
mv /usr/local/src/essential-20061022/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/
If you are using secure tmp:
mkdir /usr/local/src/tmp
chmod 777 /usr/local/src/tmp
export TMPDIR=/usr/local/src/tmp
Installing Lame:
cd /usr/local/src/lame-3.97
make && make install
Installing Libogg:
cd /usr/local/src/libogg-1.1.3
./configure && make && make install
Installing libvorbis:
cd /usr/local/src/libvorbis-1.1.2
./configure && make && make install
Installing flvtool2:
# alternative: yum install flvtool2
cd /usr/local/src/flvtool2_1.0.5_rc6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
Install MPlayer:
# alternative: yum install mplayer
cd /usr/local/src/mplayer
./configure && make && make install
Installing ffmpeg:
# removed –enable-libogg option
cd /usr/local/src/ffmpeg/
./configure –enable-libmp3lame –enable-libvorbis –disable-mmx –enable-shared
make && make install
ln -s /usr/local/lib/ /usr/lib/
ln -s /usr/local/lib/ /usr/lib/
ln -s /usr/local/lib/ /usr/lib/
ln -s /usr/local/lib/ /usr/lib/
ln -s /usr/local/lib/ /usr/lib/
— Test ————-
cp -p /usr/local/src/ffmpeg/libavformat/avio.h /usr/local/include/ffmpeg
cp -p /usr/local/src/ffmpeg/libavformat/avformat.h /usr/local/include/ffmpeg
cp -p /usr/local/src/ffmpeg/libavcodec/avcodec.h /usr/local/include/ffmpeg
Installing ffmpeg-php:
——— test 1 not works ————–
vim /usr/local/src/ffmpeg-php-0.5.0/ffmpeg-php.c
comment out “//” this line:
———test 2 WORKS!! —————
cd /usr/local/src/ffmpeg-php-
make && make install
cd /usr/local/src/ffmpeg-php-0.5.0/
make && make install
Note: Make sure this is the correct php.ini for this server.
# Read this article for the proper way of setting these
echo ‘’ >> /etc/php.ini
Restart apache:
service httpd restart
php -r ‘phpinfo();’ | grep ffmpeg
Note: up2date can be used if you don’t have yum installed.

Another piece of note found somewhere on my old hard drives:

First Install FFMPEG:
rpm -Uhv
yum update
yum install ffmpeg ffmpeg-devel
And in you can use “yum search “softwarename” to find software you are looking for. When you find the software just “yum install softwareyoufound”
Then, install FFMPEG-PHP


  • ffmpeg-0.4.9_pre1 or higher.
  • php-4.3.0 or higher
  • gd-2.0 or higher (yum install gd gd-devel)
These instructions are for Linux. I don’t know the first thing about Windows or Mac.
Building the ffmpeg-php Extension
Build and install PHP if it is not already installed
Unpack the ffmpeg-php sources
  1. tar -xjf ffmpeg-php-X.x.x.tbz2
Change to the ffmpeg-php extension directory and run phpize (included with your PHP installation) to build configuration files. NOTE: if your php installation does not include phpize, you may have to install a php-dev package for your distro (usually named: php-dev, php-devel or similar)
  1. cd ffmpeg-php-X.x.x/
  2. phpize
Configure and build the extension.
  1. ./configure && make
Install the shared extension.
  1. sudo make install
If everything went as planned, ffmpeg-php is now installed as a shared extension.


If you’ve built ffmpeg-php as a shared extension but want to make it available to all scripts by default, add to your php.ini file to load ffmpeg-php at PHP startup. Make sure to restart apache when you are done to reload php.ini.

Testing the Installation

  • Put the directory test_media and test_ffmpeg.php script under your web root somewhere (put both in the same directory).
  • Load test_ffmpeg.php into your browser.
RESULTS: You should get a listing of the methods provided by the ffmpeg-php module as well as some test output from the methods.


If you’ve the installed ffmpeg-php extension as a shared library but haven’t set it to auto-load in your php.ini file, you’ll need to use the PHP dl() function to make ffmpeg-php available to your scripts. Add the following PHP code to the beginning of scripts you want to call ffmpeg-php methods in.
$extension = “ffmpeg”;
$extension_soname = $extension . “.” . PHP_SHLIB_SUFFIX;
$extension_fullname = PHP_EXTENSION_DIR . “/” . $extension_soname;
// load extension
if(!extension_loaded($extension)) {
    dl($extension_soname) or die(“Can’t load extension $extension_fullname\n”);
Posted on Categories Linux

Leave a Reply

Your email address will not be published. Required fields are marked *