Compilation of ffmpeg and others

Sat, 21 Aug 2010 (tags:linux, ffmpeg, mplayer, lighttpd, h264)

I will try to make "how to" compile ffmpeg + x264 + mplayer + ffmpeg-php + mod_h264_streaming module for lighttpd from the source. It will be done under Debian 5 lenny stable x86 32bit version, it can be compiled under amd64 64bit as well but you need to skip steps related to the mplayers w32codecs (the w64codecs are almost empty so I don't see any point to include them on 64bit install).

1) Get some tools

sudo apt-get update
sudo apt-get install svn git yasm libfaad-dev libvorbis-dev libbz2-dev libtheora-dev wget
sudo apt-get build-dep mplayer

2) Get sources and set destination for the builds (as you can see now it's set to the /opt directory but it can point to yours home directory)

svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
git clone git://git.videolan.org/x264.git
wget http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
wget http://lags.leetcode.net/Lagarith_1320.zip
 

WHERE=/opt
#WHERE=$HOME
3) Compile ffmpeg just with any config, just to get libavf compiled (x264 is dependand on it)
cd ffmpeg
 
./configure --extra-cflags=-I$WHERE/include --extra-ldflags=-L$WHERE/lib --prefix=$WHERE \
--enable-shared --enable-gpl --enable-libvorbis --enable-pthreads --enable-postproc --enable-x11grab \
--enable-swscale --enable-nonfree --disable-mmx --disable-stripping --enable-avfilter --disable-altivec \
--disable-armv5te --disable-armv6 --disable-vis
 
make
sudo make install
4) Set path for ldconfig
sudo sh -c "echo "$WHERE/lib" >> /etc/ld.so.conf.d/my_custom.conf"
sudo ldconfig
5) Compile x264 and check if lavf support is enabled
cd ../x264
 
./configure --prefix=$WHERE --enable-shared --extra-cflags=-I$WHERE/include \ 
--extra-ldflags=-L$WHERE/lib
 
cat config.log | grep lavf:
make
sudo make install
sudo ldconfig
6) Compile ffmpeg again with x264 support enabled
cd ../ffmpeg
 
./configure --extra-cflags=-I$WHERE/include --extra-ldflags=-L$WHERE/lib \
--prefix=$WHERE --enable-shared --enable-gpl --enable-libvorbis --enable-pthreads \ 
--enable-postproc --enable-x11grab --enable-swscale --enable-nonfree \
--disable-mmx --disable-stripping --enable-avfilter --disable-altivec --disable-armv5te \
--disable-armv6 --disable-vis --enable-libx264
 
make
sudo make install
sudo ldconfig
cd ../
7) Get w32codecs ready for mplayer
tar jxvf essential-20071007.tar.bz2
sudo mkdir /usr/local/lib/codecs
sudo cp essential-20071007/* /usr/local/lib/codecs/
copy Lagarith_1320.zip