Dejan Levec

ffmpeg and x264

How to install ffmpeg with x264 codec support on Debian Lenny (5.0)?

Why is this useful? By using x264 codec rather than a FLV video format you will gain on video and audio quality.

1. We need to remove any previous ffmpeg installations.

2. Add additional repository to /etc/apt/sources.list

Open file with nano editor:

nano /etc/apt/sources.list

and add following line on the end of the file:

deb stable main

3. Install needed libraries:

apt-get install build-essential subversion git-core checkinstall yasm texi2html libfaac-dev libfaad-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libx11-dev libxfixes-dev libxvidcore4-dev zlib1g-dev libogg-dev

4. Install x264

git clone git://
cd x264
sudo checkinstall –pkgname=x264 –pkgversion \"1:0.svn`date +%Y%m%d`\" –backup=no –default

5. Install libtheora

tar xzvf libtheora-1.1.1.tar.gz
cd libtheora-1.1.1
sudo checkinstall –pkgname=libtheora –pkgversion \"1.1.1\" –backup=no –default

6. Install ffmpeg

svn checkout svn:// ffmpeg
cd ffmpeg
./configure –enable-gpl –enable-version3 –enable-nonfree –enable-pthreads –enable-libfaac –enable-libfaad –enable-libmp3lame –enable-libtheora –enable-libx264 –enable-x11grab
sudo checkinstall –pkgname=ffmpeg –pkgversion \"4:0.5+svn`date +%Y%m%d`\" –backup=no –default

7. Install qt-faststart

Normal mp4 file needs to be fully downloaded before it can be played by Flash Player. qt-faststart fixes this.

Type following command from ffmpeg source directory:

make tools/qt-faststart


ffmpeg -i -acodec libfaac -ab 128k -ac 2 -vcodec libx264 -vpre hq -crf 22 -threads 0 output.mp4
./tools/qt-faststart output.mp4 output2.mp4

Now you can play output2.mp4 by any Flash player. LongTail’s freeware JW Player is quite good, has many options and can play both mp4 and flv.

Now you can use ffmpeg to compress videos with x264 codec.

Warning: Latest ffmpeg version has some problems with FLV format and it’s impossible to convert video to .flv with it! If you need flv support try installing older version of ffmpeg (if you install it by apt-get install ffmpeg you will be able to convert to FLV but there is no x264 support).


Leave a Reply

Your email address will not be published. Required fields are marked *