Installation of FFmpeg + FFmpeg-PHP +Lame + Ruby + Mplayer + Mencoder + flv2tool


FFmpeg is a computer program that can record, convert and stream digital audio and video in numerous formats. FFmpeg is a command line tool that is composed of a collection of free software / open source libraries. It also supports grabbing and encoding in real time from a TV card.

=====================================================================

To install ffmpeg in Debian and Ubuntu servers please refer to the following URL.

http://linux.justinhartman.com/FFmpeg,_FFmpeg-PHP,_Lame,_Libogg,_Libvorbis,_FLVtool2,_Mplayer,_Mencoder,_AMR_Installation

=====================================================================


Go to your installation folder.

cd /usr/local/src

1. Lame MP3 encoder

Pure install of FFmpeg is not enough, the FLV (Flash Video Files) converted has no audio, because FLV audio codec is mp3, so you need LAME support.

Download from sourceforge.net

wget http://nchc.dl.sourceforge.net/sourceforge/lame/lame-3.96.tar.gz
tar xvzf lame-3.96.tar.gz
cd lame-3.96
./configure –enable-shared –prefix=/usr
make
make install

enable-shared to make sure FFmpeg can use LAME later. Type lame in command line to see help after install succeed.

Go to your installation folder.

cd /usr/local/src

2. Install subversion via yum, rpm or up2date (things are easier with Subversion).

For eg: If the server has yum installed, the following command would suffice.

yum install subversion

3. Download ffmpeg using subversion

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

cd ffmpeg


./configure –enable-gpl –enable-shared –enable-libmp3lame

==============================
If you are getting the following error

“Unable to create and execute files in /tmp. Set the TMPDIR environment…”
Try to unmount /tmp OR

mkdir /test ; chmod 777 /test
vi configure edit TMPDIR to /test

and execute it once again

====================
make
make install

Go to your installation folder.

cd /usr/local/src

4. Install Ruby (FLVTool2 is written in Ruby, so you have to install Ruby in server too)

FLVTool2 is a manipulation tool for Macromedia Flash Video files (FLV). It can calculate a lot of meta data, insert an onMetaData tag, cut FLV files, add cue points (onCuePoint), show the FLV structure and print meta data information in XML or YAML.

Download from Ruby site, type the following command to compile and install it:

./configure
make
make install

Note: if you have yum installed, just use

yum install ruby

Go to your installation folder.

cd /usr/local/src

5. Install FLVTool2

Download from FLVTool2 site, type the following command to compile and install it:

wget http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
tar xvzf flvtool2_1.0.5_rc6.tgz
cd flvtool2_1.0.5_rc6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

Type flvtool2 in command line to see help after install succeed.

Go to your installation folder.

cd /usr/local/src

6. Install ffmpeg-php

wget http://downloads.sourceforge.net/ffmpeg-php/ffmpeg-php-0.5.3.1.tbz2?modtime=1213135005&big_mirror=0
tar xjvf ffmpeg-php-0.5.3.1.tbz2
cd ffmpeg-php-0.5.3.1

phpize
./configure && make
make install

You will get a message as follows, which mention the path

############################
/usr/local/src/ffmpeg-php-0.5.3.1/modules/ffmpeg.so
cp ./.libs/ffmpeg.lai /usr/local/src/ffmpeg-php-0.5.3.1/modules/ffmpeg.la
PATH=”$PATH:/sbin” ldconfig -n /usr/local/src/ffmpeg-php-0.5.3.1/modules
———————————————————————-
Libraries have been installed in:
/usr/local/src/ffmpeg-php-0.5.3.1/modules

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
########################

This creates the ffmpeg.so file. Include this extension in your php.ini file.
extension=ffmpeg.so

You can find the php.ini that the the server is using with the following command.

php -i |grep php.ini

Make sure that the php.ini has the above mentioned extension directory. Also note the PATH where the shared libraries loaded.

Go to your installation folder.

cd /usr/local/src

7. Libogg + Libvorbis

Download libogg from http://downloads.xiph.org/releases/ogg/

wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
tar xvzf libogg-1.1.3.tar.gz
cd /usr/local/src/libogg-1.1.3
./configure && make && make install

Go to your installation folder.

cd /usr/local/src

Download Libvorbis from http://downloads.xiph.org/releases/ogg/

wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz
tar xvzf libvorbis-1.1.2.tar.gz
cd /usr/local/src/libvorbis-1.1.2
./configure && make && make install

Go to your installation folder.

cd /usr/local/src

8. Mplayer & Codecs

wget http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
tar xjvf essential-20071007.tar.bz2
mv /usr/local/src/essential-20071007/ /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/

Go to your installation folder.

cd /usr/local/src


wget http://www1.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc1.tar.bz2
tar xjvf MPlayer-1.0rc1.tar.bz2
cd MPlayer-1.0rc1/
./configure
make
make install

=======================

For more information and FAQs,

http://ffmpeg.mplayerhq.hu/faq.html

Click here for the steps to install FFmpeg and FFmpeg-php in a Linux ( RHEL, CentOS, Fedora) Server.

Common Issues & fixes :

1) If you are getting the following error while running ffmpeg in shell, try the following.

ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file: No such file or directory

A)
Step 1: Check if the file “libavdevice.so.52” exists in the server using the following command.

find / -name ‘libavdevice.so.*’

Step 2: You will get the directory in which the file “libavdevice.so.52” exists from the above command.
Suppose the directory is “/usr/local/lib/” in this example.

Step 3: You have to add the directory name in the file “/etc/ld.so.conf”.

Step 4: Execute the command “ldconfig”.

OR

B)
export LD_LIBRARY_PATH=/usr/local/lib:LD_LIBRARY_PATH

But this value will be cleared once you log off that session.

So it is better to save this value in bashrc

vi .bashrc
LD_LIBRARY_PATH=/usr/local/lib

After closing the file execute the command : bash

2)

If you are getting the following errors while installing ffmpeg

checking for ffmpeg headers... configure: error: ffmpeg headers not
found. Make sure you've built ffmpeg as shared libs using the --enable-
shared option 

Check whether “/usr/local/include/ffmpeg” directory is created while installing ffmpeg. If not, create this directory.

mkdir /usr/local/include/ffmpeg

Copy the necessary ffmpeg header files to “/usr/local/include/ffmpeg”.

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

One response to “Installation of FFmpeg + FFmpeg-PHP +Lame + Ruby + Mplayer + Mencoder + flv2tool

  1. Abhilash V.Nair

    Sakafi,

    Nice Blog Boss. Keep it up. 🙂


    Abhilash V.Nair

Leave a comment