Installing Ffmpeg

To install ffmpeg on a redhat server you will need to use the following example:

EXAMPLE ONLY:

The following files are required:

FFmpeg ****REQUIRES SUBVERSION ****
FFmpeg-PHP
Mplayer + Mencoder (mencoder is now built into the mplayer svn release ) ****REQUIRES SUBVERSION ****
flv2tool ****REQUIRES RUBY ****
LAME MP3 Encoder
Libogg
Libvorbis
mad

Get the requested programs:

wget www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
wget rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
wget easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
wget superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
wget downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz
wget internap.dl.sourceforge.net/sourceforge/mad/libmad-0.15.1b.tar.gz
wget internap.dl.sourceforge.net/sourceforge/flac/flac-1.1.4.tar.gz

Extract the files needed:

tar zxvf flvtool2_1.0.5_rc6.tgz
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 libmad-0.15.1b.tar.gz
tar zxvf flac-1.1.4.tar.gz

Make needed directory:

mkdir /usr/local/lib/codecs/

Copy Mplayer codecs:

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

LAME:

cd lame-3.97/
./configure
make && make install

LIBOGG:

cd libogg-1.1.3/
./configure

make && make install

LIBVORBIS:

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

FLVTOOL2:

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

FLAC:

cd flac-1.1.4/
./configure
make && make install

MAD:

cd libmad-0.15.1/
./configure
make && make install

MPLAYER:

svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd mplayer
./configure
--codecsdir=/usr/local/lib/codecs
make && make install

FFMPEG:

*** The normal configure script wants execute rights on /tmp which is undesirable ***

Create a separate 'tmp' directory for ffmpeg to use:

mkdir -p /home/ffmpeg/tmp

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

Edit the configure file to use the new 'tmp' directory:

*** Find the following ***

if test ! -z "$TMPDIR" ; then
TMPDIR1="$"
elif test ! -z "$TEMPDIR" ; then
TMPDIR1="$"
else
TMPDIR1="/tmp"
fi

*** Change to ***

if test ! -z "$TMPDIR" ; then
TMPDIR1="$"
elif test ! -z "$TEMPDIR" ; then
TMPDIR1="$"
else
TMPDIR1="/home/ffmpeg/tmp"
fi

*** End of configure edit ***

./configure --enable-libmp3lame --enable-libogg --enable-libvorbis --disable-mmx --enable-shared
make && make install

Create codec symlinks:
ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50
ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51
ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51

FFMPEG-PHP:

cd ffmpeg-php-0.5.0/
phpize
./configure
make && make install

NOTICE: Make sure this is the correct php.ini for the box. ( php -i | grep php.ini )

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

Now you will need to restart apache:

service httpd restart

To test ffmpeg-php:

php -i | grep ffmpeg

Which should return:

ffmpeg
ffmpeg support (ffmpeg-php) => enabled
ffmpeg-php version => 0.5.0
ffmpeg.allow_persistent => 0 => 0

To test flv the you can use the following test:

ffmpeg -y -i test.avi -acodec mp3 -ar 22050 -f flv test.flv