Feb 06 2010 | How to - Tutorial - Setting up ffmpegPosted by: trinita on Feb 06, 2010 |
I have recently been working on compiling ffmpeg from svn. doing a built from svn including all recent librairies, such as x264, latest lib theora and many others. Since the goal is the quality for this site and its future server, coming next month (we will be running a 2TO quad core , top notch box believe me) I m working on all server side installation..
Most of the aspects are pretty easy in fact. FFmpeg, so important for a video site, is pretty much the most complicated task that I have to do with the server admin.
I had the luck, previously, to meet Robert Swain from ffmpeg google code project, that did the actual ffmpeg install. That was worth every pennies and I can't recommend you enough to check his blog. http://rob.opendot.cl/
I wouldn't you to expect to be as lucky as I was, since he got a new job you won't probably be able to request him any freelance.
Therefore.. having a read at this tutorial could be useful for you.
During my research , I have been compiling several sources that I think are very helpul for ffmpeg installation. Since there are bunch of way to set it up, (since it can include many differents options in the ./configure -- options , depending on the lib you want to include) , I am using several tutorial I found together.
This is for ubuntu 8.0.4 LTS , so it might be compatible with many debian distros.Installing required and extra libraries:
apt-get install php5-gd php5-devhttp://doc.ubuntu-fr.org/ffmpeg
Just adding this source to the repos:
deb http://download.tuxfamily.org/3v1deb feisty 3v1n0
deb-src http://download.tuxfamily.org/3v1deb feisty 3v1n0
adding the key to access to repos:
wget http://download.tuxfamily.org/3v1deb/DD800CD9.gpg -O- | sudo apt-key add -
apt-get install build-essential subversion liba52-0.7.4-dev libgsm1-dev libxvidcore4-dev libimlib2-dev libsdl1.2-dev gettext html2text texi2html
I would not install lib-theora, liblame-dev lib-x264-dev,libamrnb-dev, libamrwb-dev neither libvorbis. We will compile these librairies from source later.
This first link was usefull to get some specific sources that are not in the main repos.
Then we follow this tuto: http://ubuntuforums.org/showpost.php?p=6963607&postcount=360
Most of my install come from it, it is frequently updated. Just read it carefully.
note: the writer doesn't include --enable-shared in the ffmpeg configuration list, if you want to built it with ffmpeg-php , you probably want to add this option..
Some link to the librairies' source (some you can find also in the tutorial above):
wget http://downloads.sourceforge.net/project/lame/lame/3.98.4/lame-3.98.4.tar.gz (important since recent ffmpeg won't accept any packet from the distro, too old)http://ffmpeg.arrozcru.org/wiki/index.php?title=Libgsm
Theora 1.1: http://theora.org/downloads/ (also take libogg-1.1.4 libvorbis-1.2.3)
Faad/Faac : http://www.audiocoding.com/downloads.html
libfaad : http://packages.debian.org/unstable/libdevel/libfaad-dev
x264 from snapshot: ftp://ftp.videolan.org/pub/videolan/x264/snapshots/ (git clone git://git.videolan.org/x264.git)
xvid codec: http://www.xvid.org/Downloads.15.0.html
Except lib theora that is broken in the distro repository , you shouldn't need to compile all these library from source, but it is a possibility. It is recommended to built libx264 from source!!
I also installed postproc: apt-get install libpostproc-dev , retrieving following package: libavcodec-dev libavcodec1d libavutil-dev libavutil1d libdc1394-13 libdc1394-13-dev libpostproc1d libraw1394-dev libtheora-dev.
I excluded,once again, libtheora,for the reason stated above
Before compiling ffmpeg, I have a look at this other tuto, explaining how to install others necessary tools for video conversion and playback.
It can be simply installled using: apt-get install flvtool2 mplayer mencoder
http://www.crucialp.com/resources/tutorials/server-administration/how-to-install-ffmpeg-ffmpeg-php-mplayer-mencoder-flv2tool-LAME-MP3-Encoder-libog.php.
Below you can have a look at my personal ffmpeg list of options, slightly different from the main tuto I used. just adding some others, based on the job Robert did for this server and from my research.
One of the most reasons for error in ffmpeg built is the following: ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file: No such file or directory
I found a very simple fix for it:export LD_LIBRARY_PATH=/usr/local/lib/
As seen on this page: http://ubuntuforums.org/archive/index.php/t-903103.html
Type ffmpeg in the terminal will display your version:
FFmpeg version SVN-r21637, Copyright (c) 2000-2010 Fabrice Bellard, et al.
built on Feb 4 2010 19:00:29 with gcc 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
configuration: --enable-gpl --enable-pthreads --enable-libvorbis --enable-version3 --enable-nonfree --enable-postproc --enable-pthreads --enable-libgsm --enable-libfaac --enable-libfaad (is now deprecated) --enable-libmp3lame --enable-libopencore-amrnb --enable- libopencore-amrwb --enable-libtheora --enable-libx264 --enable-libxvid --enable-x11grab --disable-debug --enable-shared
libavutil 50. 8. 0 / 50. 8. 0libavcodec 52.52. 0 / 52.52. 0
libavformat 52.50. 0 / 52.50. 0
libavdevice 52. 2. 0 / 52. 2. 0
libswscale 0. 9. 0 / 0. 9. 0
libpostproc 51. 2. 0 / 51. 2. 0
Hyper fast Audio and Video encoder
-------
After updating ffmpeg in november, here is the output
FFmpeg version SVN-r25721, Copyright (c) 2000-2010 the FFmpeg developers
built on Nov 11 2010 21:01:19 with gcc 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
configuration: --enable-gpl --enable-pthreads --enable-libvorbis --enable-version3 --enable-nonfree --enable-postproc --enable-pthreads --enable-libgsm --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libx264 --enable-libxvid --enable-x11grab --disable-debug --enable-shared
libavutil 50.33. 0 / 50.33. 0libavcore 0.12. 1 / 0.12. 1
libavcodec 52.94. 4 / 52.94. 4
libavformat 52.84. 0 / 52.84. 0
libavdevice 52. 2. 2 / 52. 2. 2
libavfilter 1.60. 0 / 1.60. 0
libswscale 0.12. 0 / 0.12. 0
libpostproc 51. 2. 0 / 51. 2. 0
Hyper fast Audio and Video encoder
FFMPEG-PHP
ffmpeg-php is a php module which has nothing to do with the ffmpeg dev team. It is also quite old and seems discontinued. Though, it remains a pretty important module to run many youtube like environment, thumbs creation etc.
This tuto is meant for centos install but you can adapt many stuff from it. it also make the approach of ffmpeg-php
You need to instal automate, autoconf and libtoolAbout ffmpeg-php, I recently found a more recent package.
Normally you should find the package in http://sourceforge.net/projects/ffmpeg-php/files/ but this seems broken for me as it brings a bug when making ffmpeg-php :
/root/ffmpeg-php-0.6.0/ffmpeg_frame.c:421: error: 'PIX_FMT_RGBA32'
this is a fix : http://groups.google.fr/group/ffmpeg-php/browse_thread/thread/ae3d1f2e9ac1e3a9
Looking at the svn,I found a package almost one year newer than the previous : http://ffmpeg-php.svn.sourceforge.net/viewvc/ffmpeg-php/trunk/ffmpeg-php/
look at the bottom daily tarball if you don't know how to use the svn (no url is provided). This version worked out of the box for me.
phpize./configure
make
make install
there should be the ffmpeg.so created in /usr/lib/php extensions. Dont' forget to add this in php.ini : extension=ffmpeg.so
Just restart apache and look at your phpinfo to see if it all ok
Reorder the video metadata
There are 2 tools commonly used to move the metadata of a video which make it playable without having to download it all
-setup qt-faststart
http://blogs.eciad.ca/andyan/2009/04/02/install-ffmpeg-qt-faststart/It is very simple, go in the ffmpeg folder
#svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd ffmpeg#make tools/qt-faststart
#cp -a tools/qt-faststart /usr/bin/ (and also /usr/local/bin/ depending of your OS)
- setup MP4Box
The package works fine: apt-get install gpac
what gpac does is actually moving the metada info of the file at the beginning of the converted file, allowing for viewing the video before it is fully downloadedFrom source: http://sourceforge.net/projects/gpac/files/
Compiling this library brings me a problem : "cannot find -lglut" even so lglut exists: I found the following fix
http://forums.nvidia.com/index.php?showtopic=82884
Finally I got mp4box installed along the others programs in usr/local/bin:
Well that's pretty much it. I am not willing to make of this a good tuto, as I am well aware it is not well written. This can server as example of a ffmpeg built. It is a source than rely on many others and I would like here to thanks the authors for their job , it helped me out a lot.



