Monday, January 7, 2013

Building FFMPEG for Centos


For some reason, FFMPEG on RHEL/Centos is pretty much crap for just about anything I needed so far, so the only option was building it myself. Hardly as simple as it might seem, most recipes out there are... crap. Yes, they are, really, especially when dealing with people needing it for video streaming with watermarks etc. etc. etc.

Anyway, this recipe works:

https://ffmpeg.org/trac/ffmpeg/wiki/CentosCompilationGuide

Good luck, you might need it.

UPDATE: the link above does no longer work for CentOS 5.9, at least not without some serious voodoo.
So, a cut and paste recipe to turn your relatively old linux into a media churning and streaming machine (executed as root):

rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
yum install zlib-devel autoconf automake gcc-c++  SDL-devel.x86_64 libexif.x86_64 libmcrypt.x86_64 libtool git perl-Git nasm freeglut-devel.x86_64 freetype-devel.x86_64 -y

echo "1   ImageMagic"
mkdir ~/extra_packages/
cd ~/extra_packages/
wget ftp://ftp.sunet.se/pub/multimedia/graphics/ImageMagick/linux/CentOS/x86_64/ImageMagick-6.7.9-10.x86_64.rpm
wget ftp://ftp.sunet.se/pub/multimedia/graphics/ImageMagick/linux/CentOS/x86_64/ImageMagick-devel-6.7.9-10.x86_64.rpm
yum localinstall ImageMagick-6.7.9-10.x86_64.rpm ImageMagick-devel-6.7.9-10.x86_64.rpm -y --nogpgcheck
cd -

echo "2   FFmpeg transcoder"
echo "(Based on http://ffmpeg.org/trac/ffmpeg/wiki/CentosCompilationGuide)"

mkdir ~/ffmpeg-source

echo "Yasm"
echo "Yasm is an assembler used by x264 and FFmpeg."
cd ~/ffmpeg-source
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
make
make install
cd -

echo "x264"
echo "H.264 video encoder."
cd ~/ffmpeg-source
git clone git://git.videolan.org/x264
cd x264
./configure --enable-static
make
make install
cd -

echo "LAME"
echo "MP3 audio encoder."
cd ~/ffmpeg-source
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --disable-shared --enable-nasm
make
make install
cd -

echo "libvpx"
echo "VP8 video encoder."
cd ~/ffmpeg-source
git clone http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure
make
make install
cd -

echo "vo-aacenc"
echo "VisualOn AAC audio encoder."
cd ~/ffmpeg-source
wget http://downloads.sourceforge.net/opencore-amr/vo-aacenc-0.1.2.tar.gz
tar xzvf vo-aacenc-0.1.2.tar.gz
cd vo-aacenc-0.1.2
./configure --disable-shared
make
make install
cd -

echo "FFmpeg"
cd ~/ffmpeg-source
git clone git://source.ffmpeg.org/ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-libmp3lame  --enable-libvo-aacenc --enable-libvpx --enable-libx264 --enable-version3
make
make install
ln -s /usr/local/bin/ffmpeg /bin/ffmpeg
cd -

echo "3   Exiftool"
mkdir ~/extra_packages
cd ~/extra_packages/
wget http://owl.phy.queensu.ca/~phil/exiftool/Image-ExifTool-9.04.tar.gz
tar xvzf Image-ExifTool-9.04.tar.gz
cd Image-ExifTool-9.04
perl Makefile.PL
make
make test
make install
cd -

echo "4 MP4Box"
lastdir=`pwd`
mkdir ~/MP4box
cd !$
wget http://sourceforge.net/projects/gpac/files/GPAC/GPAC%200.4.5/gpac-0.4.5.tar.gz/download
wget http://sourceforge.net/projects/gpac/files/GPAC%20extra%20libs/GPAC%20extra%20libs%200.4.5/gpac_extra_libs-0.4.5.tar.gz/download
tar -xzf gpac-0.4.5.tar.gz
tar -xzf gpac_extra_libs-0.4.5.tar.gz
cd gpac_extra_libs
cp -rf * ../gpac/extra_lib/
cd ../gpac
chmod +x configure
./configure
make lib
make apps
make install lib
make install
cp bin/gcc/libgpac.so /usr/lib/
ln -s /usr/local/bin/MP4Box /bin/MP4Box
ldconfig
cd $lastdir

No comments:

Post a Comment