Howto make your dedicated server into a media box

From EZP Knowledge Base

Jump to: navigation, search

If you are planning to roll out a website that does video conversion like the popular youtube - this document is for you.

To configure your dedicated server to serve media like this, generally we use to ffmpeg which is a popular audio/video encoder and decoder.

From the ffmpeg FAQ: FFmpeg can be hooked up with a number of external libraries to add support for more formats. None of them are used by default, their use has to be explicitly requested by passing the appropriate flags to `./configure’.

Now, if you wish to allow your users to upload content shot using mobile phones; you may need AMR codec support to decode them. Which unfortunately is not shipped with ffmpeg binary packages. So what we need to do is compile and install these codec's into ffmpeg.

Here is the full configure options


neutron:~# ffmpeg -v FFmpeg version SVN-r14147, Copyright (c) 2000-2008 Fabrice Bellard, et al. configuration: –enable-shared –enable-gpl –enable-nonfree –enable-liba52 –enable-liba52bin –enable-libamr-nb –enable-libamr-wb –enable-libfaac –enable-libfaad –enable-libfaadbin –enable-libgsm –enable-libmp3lame –enable-libtheora libavutil version: 49.7.0 libavcodec version: 51.60.0 libavformat version: 52.17.0 libavdevice version: 52.0.0 built on Jul 11 2008 06:00:59, gcc: 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)


Here is the step by step instruction to accomplish this configuration:

Since the libraries are installed while compiling from source to /usr/local/lib; we must include this in the linux loaders config file, like so:


neutron:~# vi /etc/ld.so.conf.d/usrlocal.conf


and ensure the following line is contained in it:


neutron:~# cat /etc/ld.so.conf.d/usrlocal.conf /usr/local/lib neutron:~#


1. Now you must download and install AMR codec libraries from

http://www.penguin.cz/~utx/amr

You will need to download both amrnb and amrwb.


neutron:~# wget http://ftp.penguin.cz/pub/users/utx/amr/amrnb-7.0.0.2.tar.bz2; wget http://ftp.penguin.cz/pub/users/utx/amr/amrwb-7.0.0.3.tar.bz2


Next, we need to untar these files:


neutron:~# tar xfvj amrnb-7.0.0.2.tar.bz2

neutron:~# tar xfvj amrwb-7.0.0.3.tar.bz2


Next, we must run the following command from inside the source directory:


neutron:~# cd amrnb-7.0.0.2; ./configure && make && make install

neutron:~# cd amrwb-7.0.0.2; ./configure && make && make install


This will install the amr(nb and wb) header files in /usr/local/include which is required by ffmpeg.

      • Please note that you do not have to install the codes from 3gp.org as this will be automatically downloaded in amr installation***

2. Now you must download and install FAAC and FAAD2 from:

http://www.audiocoding.com/downloads.html

And untar them as we did for the amrnb and amrwb above.


neutron:~# wget http://downloads.sourceforge.net/faac/faad2-2.6.1.tar.gz; http://downloads.sourceforge.net/faac/faac-1.26.tar.gz

neutron:~# tar xfvz faad2-2.6.1.tar.gz

neutron:~# tar xfvz faac-1.26.tar.gz


And again, we must compile them in the same way, from inside the source directory you must run the following commands:


neutron:~# cd faad2-2.6.1; ./bootstrap && ./configure && make && make install

neutron:~# cd faac-1.26; ./bootstrap && ./configure && make && make install


3. Download and install liba52

http://liba52.sourceforge.net/downloads.html

As before, we must download and untar this:


neutron:~# wget http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz

neutron:~# tar xfvz a52dec-0.7.4.tar.gz


Compile from within the source directory:


neutron:~# cd a52dec-0.7.4; ./configure && make && make install


4. Now you have to install LAME

http://lame.sourceforge.net/index.php


neutron:~# wget http://downloads.sourceforge.net/lame/lame-398-2.tar.gz neutron:~# tar xfvz lame-398-2.tar.gz


Then install it:


neutron:~# cd lame-398-2; ./configure && make && make install


5. We need the theora development libraries which are available in the apt repository. You can do an apt-cache search theora (debian) or yum search theora (centos) according to the distribution you use.

In debian sarge the following command should be fine:


apt-get install libtheora-dev


In CentOs:


yum install libtheora-dev


Done!

Now its time to get the ffmpeg sources. Please note that ffmpeg does not have an “official release”. So you must either checkout ffmpeg from svn or use the daily snapshot available at:

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


neutron:~# wget http://ffmpeg.mplayerhq.hu/ffmpeg-export-snapshot.tar.bz2


Untar the sources and cd to the source directory:


neutron:~# tar xfvj ffmpeg-export-snapshot.tar.bz2

neutron:~# cd ffmpeg-export-snapshot


Then run the following commands:


neutron:~# ./configure –enable-shared –enable-gpl –enable-nonfree –enable-liba52 –enable-liba52bin –enable-libamr-nb –enable-libamr-wb –enable-libfaac –enable-libfaad –enable-libfaadbin –enable-libgsm –enable-libmp3lame –enable-libtheora

neutron:~# make

neutron:~# make install


If everything goes well you should now have ffmpeg installed. If there is an error, check the file configure.err in the ffmpeg source directory for the cause.

Finally, you must check if all shared libraries are loaded fine. You can run the following commands to check this:


neutron:~# which ffmpeg /usr/local/bin/ffmpeg neutron:~# ldd /usr/local/bin/ffmpeg linux-gate.so.1 => (0×001b2000) libavdevice.so.52 => /usr/local/lib/libavdevice.so.52 (0×005e2000) libavformat.so.52 => /usr/local/lib/libavformat.so.52 (0×009a4000) libavcodec.so.51 => /usr/local/lib/libavcodec.so.51 (0×00a43000) libavutil.so.49 => /usr/local/lib/libavutil.so.49 (0×00110000) libm.so.6 => /lib/tls/libm.so.6 (0×0011f000) libc.so.6 => /lib/tls/libc.so.6 (0×007c7000) libz.so.1 => /usr/lib/libz.so.1 (0×0026d000) libdl.so.2 => /lib/tls/libdl.so.2 (0×00649000) libamrnb.so.3 => /usr/local/lib/libamrnb.so.3 (0×00144000) libamrwb.so.3 => /usr/local/lib/libamrwb.so.3 (0×00180000) libfaac.so.0 => /usr/local/lib/libfaac.so.0 (0×001b3000) libgsm.so.1 => /usr/lib/libgsm.so.1 (0×00582000) libmp3lame.so.0 => /usr/local/lib/libmp3lame.so.0 (0×001c4000) libtheora.so.0 => /usr/lib/libtheora.so.0 (0×00281000) /lib/ld-linux.so.2 (0×00737000) libogg.so.0 => /usr/lib/libogg.so.0 (0×007ad000) neutron:~#


Sometimes you will receive a ”cannot load shared library” error while running ffmpeg or library “not found” in the ldd output. This is caused because you have not created/updated the necessary links and cache (for use by the run-time linker, ld.so) to the most recent shared libraries.

You can fix this error simply by running the following command:


neutron:~# ldconfig


Please do not forget to include /usr/local/lib in your ld.so.conf which was mentioned at the start of this article by editing the file /etc/ld.so.conf.d/usrlocal.conf. You can also add /usr/local/lib directly to ld.so.conf in older versions of GNU/Linux that does not use the /etc/ld.so.conf.d/ directory scheme.


WARNING:

libamr is copyrighted without any sort of license grant. This means that you can use it if you legally obtained it but you are not allowed to redistribute it in any way. Any FFmpeg binaries with libamr support you create are non-free and not redistributable!

REFERENCES:

http://ffmpeg.mplayerhq.hu/general.html#SEC1

At EZProvider Networks, Inc. we can help you in getting a Dedicated server or a Xen Powered VPS with ffmpeg preinstalled. If you are interested in this, please get in touch with us at sales@ezprovider.netThis e-mail address is being protected from spambots. You need JavaScript enabled to view it for more information!