How to Install FFmpeg on a shared Server ” Dreamhost”

Some of you, probably, will or want to create a video website like YouTube (YoutTube clone). To be able to do so you’re going to need ffmpeg, lame, libvorbis and other programs installed on your server. Today, I’ll explain how to install them easily.
There are two methods to do it, the dirty one and the easy (very easy) one. I’ll start with the dirty one:

How to manually install ffmpeg, lame, libogg, libvorbis…

This is exactly how I did it last year  (how we did it :D cos Fay helped me)  :P
First of all, you have to login to your server using SSH as the owner account of your directory, and because I’m not a Linux user I used Putty (http://www.putty.org)

Putty fahdos

Create these directories, and set their correct permissions

$ mkdir bin lib tmp
$ chmod 777 tmp
$ chmod 775 bin lib

mkdir: creates the directory
chmod: sets the correct permissions for the directory

Export these variables

$ export TMPDIR=$HOME/tmp
$ export PATH=$HOME/bin:$PATH
$ export LD_LIBRARY_PATH=$HOME/lib:/usr/local/lib:$LD_LIBRARY_PATH
$ export CPATH=$HOME/include:/usr/local/include:$CPATH
$ export LIBRARY_PATH=$HOME/lib:/usr/local/lib:$LIBRARY_PATH
$ mkdir src
$ cd src

Autoconf

$ wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.63.tar.gz
$ tar -zxf autoconf-2.63.tar.gz
$ cd autoconf-2.63
$ ./configure –prefix=$HOME
$ make && make install
$ cd ..

LAME:

$ wget http://nchc.dl.sourceforge.net/sourceforge/lame/lame-398.tar.gz
$ tar -zxvf lame-398.tar.gz
$ cd lame-398
$ ./configure "–prefix=$HOME" "–enable-shared"
$ make && make install
$ cd..

Libogg

$ wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
$ tar -zxf libogg-1.1.3.tar.gz
$ cd libogg-1.1.3
$ ./configure –prefix=$HOME
$ make && make install
$ cd ..

Libvorbis

$ wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.0.tar.gz
$ tar -zxf libvorbis-1.2.0.tar.gz
$ cd libvorbis-1.2.0
$ ./configure –prefix=$HOME
$ make && make install
$ cd ..

Mplayer:

$ wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
$ bunzip2 essential-20061022.tar.bz2
$ tar -xf essential-20061022.tar
$ mv essential-20061022 $HOME/lib
$ wget http://www3.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc1.tar.bz2
$ bunzip2 MPlayer-1.0rc1.tar.bz2
$ tar -xf MPlayer-1.0rc1.tar
$ cd MPlayer-1.0rc1
$ ./configure –prefix=$HOME –with-codecsdir=$HOME/lib/essential-20061022/
$ make && make install
$ cd ..

Amr

$ wget http://ftp.penguin.cz/pub/users/utx/amr/amrnb-7.0.0.0.tar.bz2
$ wget http://ftp.penguin.cz/pub/users/utx/amr/amrwb-7.0.0.2.tar.bz2
$ gunzip  amrnb-7.0.0.0.tar.bz2
$ gunzip  amrwb-7.0.0.2.tar.bz2
$ tar xvf  amrnb-7.0.0.0.tar
$ tar xvf  amrwb-7.0.0.2.tar
$ cd amrnb-7.0.0.0
$ ./configure –prefix=$HOME
$ make && make install
$ cd ..
$ cd amrwb-7.0.0.2
$ ./configure –prefix=$HOME
$ make && make install
$ cd ..

FFmpeg

$ svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
$ cd ffmpeg
$ ./configure –prefix=$HOME –cross-compile –enable-shared –enable-libmp3lame –enable-libamr-nb –enable-libamr-wb –extra-cflags=-I$HOME/include –extra-ldflags=-L$HOME/lib
$ make && make install
$ cd..

Test :
Now you can test to convert for exemple an AVI file to flv.
Here is the command I use to generate FLVs:

$ /path/to/ffmpeg -i /path/to/inputfile.avi -acodec mp3 -ab 32 -ac 1 -ar 44100 /path/to/outputfile.flv

Exemple :

$ bin/ffmpeg -i www/videos/test.avi test.flv

Cooool, It works
But there’s still one problem; after restarting your server you’ll get this error while trying to do the test again

[fahdos]$ bin/ffmpeg -i www/test2.avi www/test2.flv
bin/ffmpeg: error while loading shared libraries: libavformat.so.51: cannot open shared object file: No such file or directory

The solution is quite simple

Login with SSH again and tape:

$ vi .bash_profile
i

Then past these lines:

export TMPDIR=$HOME/tmp
export PATH=$HOME/bin:$PATH
export LD_LIBRARY_PATH=$HOME/lib:/usr/local/lib:$LD_LIBRARY_PATH
export CPATH=$HOME/include:/usr/local/include:$CPATH
export LIBRARY_PATH=$HOME/lib:/usr/local/lib:$LIBRARY_PATH

Tape the Esc key then tape

:wq

Restart your server and test it again, now it will work

How to Automatically install ffmpeg, lame, libogg, libvorbis…

We will use The ffmpeginstall Script for the shared server:
This series of scripts will install all required modules for running video streaming application websites in a shared environment. A number of webhosts provides large amount of disk space and normal shell access to your Linux server. So now you can setup your own ffmpeg environment in a shared account.
To do so, just visit www.ffmpeg.sherin.in
It will install all you need with just few clicks. Documentation
NB: the website maybe down, so please download the file from :

  Automatic Installation (11.8 KiB, 1,884 hits)


For instruction, open the INSTALL File.

Have Fun :D