-
Setup Red5 and FFMPEG on Ubuntu 8.04
Posted on February 20th, 2009 2 comments
Recently my company asked me to work on a video related project that allows users to upload videos in various formats, record videos through a web cam, and of course play back those user generated videos. After some investigation I decided to use the combination of Red5 Flash streaming server and FFMPEG for video conversion (from different formats to FLV). Both are open source thus free of charge. However, setting up FFMPEG on Linux is nothing but a daunting task. Literally there are tens of software to install and their versions have to be the right combination. With some research and good tips from a few sources I was able to install it and compile this step-by-step instruction on setting up both Red5 and FFMEPG and hopefully it can save bunch of your time.Please note that a wrong software version could lead to compatibility issues, so I can’t guarantee it will work if you don’t download the version I specified in the instructions. This instruction is targeted to Ubuntu 8.04, but with some tweaks it should work for all linux O/S
Setup Red5 v0.7.0 on Ubuntu Hardy 8.04
Prerequisits
Please note that while installing java-package, you need to force install and agree to Suns Java service agreement (F12 in command line, or click on yes if using package manager)
sudo apt-get install java-package
sudo apt-get install sun-java6-jdk
sudo apt-get install sun-java6-jre
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-sun/Download Red5 v0.7.0
http://www.red5.fr/release/0.7.0/debian/red5_0.7.0_all.deb
Install Red 5
sudo dpkg -i red5_0.7.0_all.debOnce installed, you can start/stop/restart by:
sudo /etc/init.d/red5 start|stop|restartRed5 is installed under the following directory by default:
/usr/lib/red5
To verify installation, use the port 5080 to test Red5:
run some demo and make sure everything works
Setup FFMPEG on Ubuntu Hardy 8.04
First make sure the system is up to date
sudo apt-get update
sudo apt-get upgradePrerequisites
sudo apt-get install libjpeg-progs libjpeg62 libjpeg62-dev
sudo apt-get install libsdl1.2-dev php5-dev build-essential
sudo apt-get install unzip subversion ruby libcurses-rubyMake a dir for downloads and operations
mkdir /usr/local/ffmpegsource
cd /usr/local/ffmpegsourceDownload software
- MPlayer Binary Codec Packages: http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
- FLVTool2: http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
- Lame: http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
- Libogg: http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
- Ffmpeg-php: http://downloads.sourceforge.net/ffmpeg-php/ffmpeg-php-0.6.0.tbz2
- libvorbis: http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.0.tar.gz
- amrnb: http://ftp.penguin.cz/pub/users/utx/amr/amrnb-7.0.0.2.tar.bz2
- amrwb: http://ftp.penguin.cz/pub/users/utx/amr/amrwb-7.0.0.3.tar.bz2
- libtheora: http://downloads.xiph.org/releases/theora/libtheora-1.0beta3.tar.gz
Unzip the downloaded files
tar zxvf lame-3.97.tar.gz
tar zxvf libogg-1.1.3.tar.gz
tar zxvf libvorbis-1.2.0.tar.gz
tar zxvf flvtool2-1.0.6.tgz
tar jxvf essential-20071007.tar.bz2
tar jxvf ffmpeg-php-0.6.0.tbz2
bzip2 -cd amrnb-7.0.0.2.tar.bz2 | tar xvf -
bzip2 -cd amrwb-7.0.0.3.tar.bz2 | tar xvf -
tar zxvf libtheora-1.0beta3.tar.gzUse Subversion to checkout ffmpeg
svn co -r 17311 svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn co -r 28578 svn://svn.mplayerhq.hu/mplayer/trunk mplayer
go to mplayer dir and run svn update:
cd /usr/local/ffmpegsource/mplayer
svn updateCopy Codecs for mplayer
sudo mkdir /usr/local/lib/codecs
sudo mv /usr/local/ffmpegsource/essential-20071007/* /usr/local/lib/codecs/
sudo chmod -R 755 /usr/local/lib/codecs/
make tmp dir for mplayer
sudo mkdir /usr/local/ffmpegsource/tmp
sudo chmod 777 /usr/local/ffmpegsource/tmp
export TMPDIR=/usr/local/ffmpegsource/tmpInstall lame
cd /usr/local/ffmpegsource/lame-3.97
./configure
sudo make && sudo make installInstall libogg
cd /usr/local/ffmpegsource/libogg-1.1.3
./configure
sudo make && sudo make installInstall libvorbis
cd /usr/local/ffmpegsource/libvorbis-1.2.0
./configure
sudo make && sudo make installInstall flvtool2
cd /usr/local/ffmpegsource/flvtool2-1.0.6/
ruby setup.rb config
ruby setup.rb setup
sudo ruby setup.rb installInstall mplayer & mencoder
cd /usr/local/ffmpegsource/mplayer
./configure --enable-jpeg
sudo make && sudo make installInstall AMR
AMRNB
cd /usr/local/ffmpegsource/amrnb-7.0.0.2
./configure
sudo make && sudo make install
AMRWB
cd /usr/local/ffmpegsource/amrwb-7.0.0.3
./configure
sudo make && sudo make installInstall libtheora (for ogg video encoding)
cd /usr/local/ffmpegsource/libtheora-1.0beta3
./configure
sudo make && sudo make installInstall ffmpeg
cd /usr/local/ffmpegsource/ffmpeg/
./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared --enable-libamr-nb --enable-libamr-wb --enable-nonfree --enable-libtheora
sudo make
sudo make install
sudo ln -s /usr/local/lib/libavdevice.so.52 /usr/lib/libavdevice.so.52
sudo ln -s /usr/local/lib/libavformat.so.52 /usr/lib/libavformat.so.52
sudo ln -s /usr/local/lib/libavcodec.so.52 /usr/lib/libavcodec.so.52
sudo ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
sudo ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
sudo ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
sudo ln -s /usr/local/lib/libamrnb.so.3 /usr/lib/libamrnb.so.3
sudo ln -s /usr/local/lib/libamrwb.so.3 /usr/lib/libamrwb.so.3Install ffmpeg-php
cd /usr/local/ffmpegsource/ffmpeg-php-0.6.0/
phpize
./configure
make
make install
modify php.ini to load ffmpeg-php and restart apache
vim /etc/php5/apache2/php.ini
extension=ffmpeg.so (add this line to the end of the file)
sudo /etc/init.d/apache2 restartTest your ffmpeg setup
There are many ways to test your ffmpeg setup such as using command line. But using the PHP class phpvideotoolkit to test your setup and quick and easy.
You can download the toolkit at:
Run the examples provided and see if everything works as expected.
That’s all. Hopefully this can help you save some time and any comment is welcomed!
Resources
- http://osflash.org/red5/ubuntu804
- http://luar.com.hk/blog/?p=669
- http://vexxhost.com/blog/2007/03/03/installing-ffmpeg-ffmpeg-php-mplayer-mencoder-flv2tool-lame-mp3-encoder-libogg-%E2%80%93-the-easy-way/
- http://rootit.org/2008/06/installing-ffmpeg-ffmpeg-php-other-dependencies-for-clipshare/
- FFmpeg, FFmpeg-PHP, Lame, Libogg, Libvorbis, FLVtool2, Mplayer, Mencoder, AMR Installation
- http://forums.theplanet.com/index.php?showtopic=64541
- http://luar.com.hk/blog/?p=670


