domenica 30 novembre 2008

[Basics How-To] How i installed/built ffmpeg with mp3, amr, x264, theora, vorbis, xvid support on Kubuntu Hardy Heron 64-bit


Due to license restrictions the ffmpeg binary/package in K/X/Ubuntu repositories the encoding in restricted formats (such as mp3) is not possible by default. Googling around i found out a lot of different guides for ffmpeg installation, but focusing on one format at a time, or enabling only some of ffmpeg features. Here's a (tested) synthesis of all the guides i found. Credits after the howto.

Be warned that i started from a long-time installation, so some more libraries than stated may need to be installed.

Said this, here we go.

We need to remove the repository package and then to install (or compile) the dependencies needed

First a bit of cleansing

$ sudo apt-get remove ffmpeg

Then some utilities & libraries
$ sudo apt-get install git-core checkinstall build-essential subversion liblame-dev libfaad-dev libfaac-dev libxvidcore4-dev libx264-dev libdts-dev libgsm1-dev libtheora-dev libvorbis-dev libdc1394-13-dev libraw1394-dev

Now we have to create a dir to download the source code for ffmpeg and related dependencies
$ mkdir src

Move inside the newly created dir
$ cd src

Now we have to get all of the needed code through subversion, git and wget
$ svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
$ git clone git://git.videolan.org/x264.git
$ 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
$ wget http://www.tortall.net/projects/yasm/releases/yasm-0.7.2.tar.gz

Untar the tarballs
$ tar -xjvf amrnb-7.0.0.2.tar.bz2
$ tar -xjvf amrwb-7.0.0.3.tar.bz2
$ tar -xzvf yasm-0.7.2.tar.gz

Now some compile&install using checkinstall.
Checkinstall is an application meant to replace the 'make install' final command in the process of software installation, by building and installing a .deb (or .rpm or .tgz) package, thus allowing the tracking of the change made, easing software removal.
The output of the process will be a bunch of installed binary packages, removable through dpkg ($sudo dpkg -r [package_name])

Yasm is a modular assembler that will optimize x264 code for MMX/SSE, thus improving encoding speed. The package in Hardy repository is not-so-up-to-date so let's build it.
$ cd yasm-0.7.2
$ ./configure
$ make
$ sudo checkinstall
$ cd ..

Libamr is the audio encoder/decoder for 3gp format (don't know why, checkinstall isn't successful with these)
$ cd amrnb-7.0.0.2
$ ./configure --prefix=/usr
$ make
$ sudo make install
$ cd ..

$ cd amrwb-7.0.0.3
$ ./configure --prefix=/usr
$ make
$ sudo make install
$ cd ..

From Wikipedia: x264 is a free software library for encoding H.264/MPEG-4 AVC video streams
$ cd x264
$ ./configure --prefix=/usr --enable-shared
$ make
$ sudo checkinstall --pkgname=x264 --pkgversion "1:0.svn`date +%Y%m%d`-0.0ubuntu1"
$ sudo ldconfig
$ cd ..

At last, here we go with ffmpeg km-long configuration line, then the usual make && checkinstall
$ cd ffmpeg
$ ./configure --enable-gpl --enable-swscale --enable-pthreads --enable-libvorbis --enable-libtheora --enable-libvorbis --enable-libgsm --enable-libdc1394 --disable-debug --enable-shared --enable-libmp3lame --enable-libfaad --enable-libfaac --disable-vhook --enable-libxvid --enable-libx264 --enable-postproc --enable-libamr-nb --enable-libamr-wb --enable-avfilter --enable-nonfree --prefix=/usr
$ make
$ sudo checkinstall

And that's it!

Credits to:
http://symbiotix.net/articles/compiling-ffmpeg-mp3-ubuntu-revised-ubuntu-gutsy-server
http://po-ru.com/diary/up-to-date-ffmpeg-on-ubuntu-hardy/
http://ubuntuforums.org/showthread.php?t=491885

http://ubuntuforums.org/showthread.php?t=786095&highlight=libx264
FFMpeg Documentation & http://howto-pages.org/ffmpeg/ for software usage help

Don't forget myself...... ^^

Nessun commento: