On the last few months, we have seen a lot of customers trying to setup his own Video Sharing site (ex: youtube clone) with no luck, the implementation it’s not that hard to setup your linux server to allow video streaming. There are a lot of youtube sites around that may do this, what you only need is to setup your linux system to work with the requirements. Due this we have made this HOW TO FFMPEG post so customers and non-customers would do this by their end.
Requirements:
FFMPEG
FFMPEG-PHP
Mplayer
Mencoder
flv2tool (RUBY ON RAILS REQUIRED)
LAME MP3 Encoder
Libogg
Libvorbis
—————————–
1) We download all the necessary packages.
-
cd /usr/local/src
-
wget http://www.serverbuddies.com/files/ffmpeg/essential-20061022.tar.bz2
-
wget http://www.serverbuddies.com/files/ffmpeg/ffmpeg-php-0.5.0.tbz2
-
wget http://www.serverbuddies.com/files/ffmpeg/flvtool2_1.0.5_rc6.tgz
-
wget http://www.serverbuddies.com/files/ffmpeg/lame-3.97.tar.gz
-
wget http://www.serverbuddies.com/files/ffmpeg/libogg-1.1.3.tar.gz
-
wget http://www.serverbuddies.com/files/ffmpeg/libvorbis-1.1.2.tar.gz
-
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
-
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
2) in order to install all the packages, we extract all of them.
-
tar xzvf flvtool2_1.0.5_rc6.tgz
-
tar xzvf lame-3.97.tar.gz
-
tar xzvf libogg-1.1.3.tar.gz
-
tar xzvf libvorbis-1.1.2.tar.gz
-
tar xzvf flvtool2_1.0.5_rc6.tgz
-
tar xjvf essential-20061022.tar.bz2
-
tar xjvf ffmpeg-php-0.5.0.tbz2
3) We create a codecs directory so we can use it as default codec dir later. Then we copy the mplayer codecs to the new directory.
-
mkdir /usr/local/lib/codecs/
-
mv /usr/local/src/essential-20061022/* /usr/local/lib/codecs/
-
chmod -R 755 /usr/local/lib/codecs/
4) We create a temporary TMP dir in order to safe compile everything.
-
mkdir /usr/local/src/tmp
-
chmod 777 /usr/local/src/tmp
-
export TMPDIR=/usr/local/src/tmp
5) We start compiling & installing packages
a) For LAME:
-
cd /usr/local/src/lame-3.97
-
./configure
-
make
-
make install
b) For LIBOGG:
-
cd /usr/local/src/libogg-1.1.3
-
./configure
-
make
-
make install
c) For LIBVORBIS:
-
cd /usr/local/src/libvorbis-1.1.2
-
./configure
-
make
-
make install
d) For FLVTOOL2:
-
cd /usr/local/src/flvtool2_1.0.5_rc6/
-
ruby setup.rb config
-
ruby setup.rb setup
-
ruby setup.rb install
e) For MPlayer:
-
cd /usr/local/src/mplayer
-
./configure
-
make
-
make install
f) For FFMPEG:
-
cd /usr/local/src/ffmpeg/
-
./configure –enable-libmp3lame –enable-shared
-
make
-
make install
Some necessary linking,
-
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
e) For FFMPEG-PHP:
-
cd /usr/local/src/ffmpeg-php-0.5.0/
-
phpize
-
./configure
-
make
-
make install
Finally, we include the ffmpeg-php module to our php.ini
-
echo ‘extension=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ffmpeg.so’ >> /usr/local/Zend/etc/php.ini
Restart apache:
-
service httpd restart
DONE!
Your installation is finish, now you need to check if the video streamin is working correctly on your website.
Keep in mind that most of the sites have different video rate conversion, this does not mean the installation is wrong, you will need to look on the PHP code of your video streaming site to see if its using ffmpeg and mencoder command line properly.
One Response to “HOW-TO FFMPEG under Linux.”
Leave a Reply
You must be logged in to post a comment.
2self-evident…
…