Saturday 31 March 2012

FFMPEG Complete Install on RedHat 6.0

FFMPEG installation:


first check if subversion is installed on server:

which svn

to install:

yum install subversion

then ==>>

Following are the steps to install FFmpeg + FFmpeg-PHP + Mplayer + Mencoder + flv2tool + LAME MP3 Encoder + Libog on a Linux

server or VPS Hosting Manually. There are many automated scripts available which install these but its better to do it

manually as in case of an error occuring during the installation process, we can stop the installation and fix them. These

steps also include the common fixes for such errors.


mkdir /usr/local/src/ffmpeg_mods


cd /usr/local/src/ffmpeg_mods

DOWNLOAD MODULES

wget http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-amd64-20071007.tar.bz2
wget http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
wget http://sourceforge.net/projects/lame/files/lame/3.99/lame-3.99.tar.gz/download
wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download
wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz

EXTRACT MODULES

tar zxvf lame-3.99.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-amd64-20071007.tar.bz2
tar jxvf ffmpeg-php-0.6.0.tbz2

CREATING A FOLDER TO SAVE Linux DLLs

mkdir /usr/local/lib/codecs

CHECK IF ALL PRE_REQUIREMENTS ARE MET

rpm -qa gcc   
rpm -qa |grep gcc   
rpm -qa |grep lib   
rpm -qa |grep libcpp   
rpm -qa |grep libgcc   
rpm -qa |grep ruby   
rpm -qa |grep ncurses-devel
rpm -qa |grep gcc-c++

DOWNLOAD Mplayer & FFMPEG

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

cd /usr/local/src/ffmpeg_mods/mplayer/
svn update   

cd ..   

mv essential-amd64-20071007/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/   

## INSTALLING MODULES:

1] LAME

cd lame-3.99   
./configure   
make   
make install

2] LIBOGG

cd ../libogg-1.1.3
./configure --enable-shared && make && make install

rpm -qa |grep gcc*            ; If you don't have gcc-c++ you must install it here
                    ; Install gcc-c++ and try again.

./configure --enable-shared && make && make install
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

3] LIBVORBIS

cd ../libvorbis-1.1.2   
./configure && make && make install   

cd ../flvtool2_1.0.5_rc6   
ruby setup.rb config   
ruby setup.rb setup   
ruby setup.rb install   

4] MPLAYER

cd ../mplayer/   
./configure && make && make install   

5] FFMPEG

cd ../ffmpeg/   
./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared
make   
make install   
export LD_LIBRARY_PATH=/usr/local/lib/
ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50
ln -s /usr/local/lib/libavformat.so.52 /usr/lib/libavformat.so.52
ln -s /usr/local/lib/libavcodec.so.52 /usr/lib/libavcodec.so.52
ln -s /usr/local/lib/libavutil.so.50 /usr/lib/libavutil.so.50
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0

6] FFMPEG-PHP

cd ../ffmpeg-php-0.6.0
phpize                    ; Since I was installing this on custom RedHat, I had to install php-devel ...
                    ; ... and in order to install that I had to install autoconf and automake
                    ; If you are in same situation then you can try a) & b) else, skip it !!

    a) INSTALL AUTOCONF
        wget http://mirror.centos.org/centos/6/os/i386/Packages/autoconf-2.63-5.1.el6.noarch.rpm
        rpm -ivh autoconf-2.63-5.1.el6.noarch.rpm

    b) INSTALL AUTOMAKE
        wget ftp://mirror.switch.ch/pool/1/mirror/scientificlinux/6.1/x86_64/os/Packages/automake-1.11.1-

1.2.el6.noarch.rpm
        rpm -ivh automake-1.11.1-1.2.el6.noarch.rpm

    c) Now, you can install php-devel

        wget ftp://ftp.ntua.gr/pub/linux/scientificlinux/6.0/x86_64/os/Packages/php-devel-5.3.2-6.el6.x86_64.rpm
        rpm -Uvh php-devel-5.3.2-6.el6.x86_64.rpm --nodeps

cd ../ffmpeg-php-0.6.0
phpize   

./configure
make                    ; If you get any errors regarding undeclared functions in ffmpeg_frame.c or any .c    

                    ; file just do this

cp /usr/local/include/libavcodec/* /usr/local/include/ffmpeg/
cp /usr/local/include/libavcore/* /usr/local/include/ffmpeg/
cp /usr/local/include/libavdevice/* /usr/local/include/ffmpeg/
cp /usr/local/include/libavfilter/* /usr/local/include/ffmpeg/
cp /usr/local/include/libavformat/* /usr/local/include/ffmpeg/
cp /usr/local/include/libavutil/* /usr/local/include/ffmpeg/
cp /usr/local/include/libswscale/* /usr/local/include/ffmpeg/

Although, you might have to replace "PIX_FMT_RGBA32" with "PIX_FMT_RGBA" everywhere in file ffmepg_frame.c

make
make install

echo 'extension=ffmpeg.so' >> /etc/php.ini

NOTICE: Make sure this is the correct php.ini for the box!!

RESTART APACHE

service httpd restart
       
php -m |grep ffmpeg            ; Just confirm if it is there ;)

CHECK BINARY PATHS FOR THE MODULES

[root@server ffmpeg-php-0.6.0]# which ffmpeg
/usr/local/bin/ffmpeg
[root@server ffmpeg-php-0.6.0]# which mplayer
/usr/local/bin/mplayer
[root@server ffmpeg-php-0.6.0]# php -m |grep ffmpeg
ffmpeg
[root@server ffmpeg-php-0.6.0]# which lame
/usr/local/bin/lame
[root@server ffmpeg-php-0.6.0]# which flvtool2
/usr/bin/flvtool2


Now, before you check the version for ffmpeg you need to do this.

Check to see if /usr/local/lib exists on this file
cat /etc/ld.so.conf

If not
echo /usr/local/lib >>/etc/ld.so.conf

cat/etc/ld.so.conf Now check to see if (/usr/local/lib exist)
save file
ldconfig

Now,

ffmpeg -V

Done...!!!

2 comments:

  1. after these commands..:

    svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
    svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
    cd /usr/local/src/ffmpeg_mods/mplayer/

    the cd failed no such file or directory

    please advise, thank you

    ReplyDelete
    Replies
    1. svn creates directories right inside the directory at which you run the command. In my case, its /usr/local/src/ffmpeg_mods/

      please check the directory at which you did svn :)

      most probably /usr/local/src/

      Delete