Peuchele bio photo

Peuchele

Pedí pollo que yo pago la diferencia!

Email

I’ve adapted the instructions from this Ubuntu thread for Debian Lenny.

The original idea was to build ffmpeg with AAC support, but then I’ve found some other problems with mp3 codec, so I needed to apply a patch and rebuild everything.

So, I’m writing all the procedures in this post in a few steps, hoping that I’m not forgetting anything. I know that some steps could be avoided (e.g. building ffmpeg twice), but I’ll just transcribe everything the way that worked for me (as I remember).

First try

First edit your aptitude sources list

nano /etc/apt/sources.list

Add the following repositories

deb http://www.debian-multimedia.org stable main
deb http://www.backports.org/debian lenny-backports main contrib non-free

Update

sudo apt-get update

Remove current ffmpeg (if installed)

sudo apt-get remove ffmpeg x264 libx264-dev

Install necessary packages for the build. Note that I’ve removed libvpx-dev from the original Ubuntu thread.

sudo apt-get install build-essential subversion git-core checkinstall yasm texi2html \
    libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev \
    libtheora-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev \
    zlib1g-dev

Build and install x264.

cd
git clone git://git.videolan.org/x264.git
cd x264
./configure
make
sudo checkinstall --pkgname=x264 --pkgversion "2:0.`grep X264_BUILD x264.h -m1 | \
    cut -d' ' -f3`.`git rev-list HEAD | wc -l`+git`git rev-list HEAD -n 1 | \
    head -c 7`" --backup=no --deldoc=yes --fstrans=no --default

Build and install ffmpeg. Note that I’ve removed the option –enable-libtheora and –enable-libvpx from the original Ubuntu thread.

cd
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc \
    --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb \
    --enable-libopencore-amrwb --enable-libvorbis \
    --enable-libx264 --enable-libxvid --enable-x11grab
make
sudo checkinstall --pkgname=ffmpeg --pkgversion "4:SVN-r`LANG=C svn info | \
    grep Revision | awk '{ print $NF }'`" --backup=no --deldoc=yes --fstrans=no \
    --default
hash x264 ffmpeg ffplay

Almost there

Ok, everything works perfectly until I try to convert a video and I get the following error:

lame: output buffer too small

After a bit of googling, I’ve found a patch in this post, with an interesting discussion regarding to whom should fix the problem (ffmpeg vs. lame). It is also suggested to downgrade the lame library, but I’ve tried that and didn’t worked for me, so in summary, let’s simply apply this ffmpeg patch and everything will be fine.

  1. Go to the ffmpeg source directory and get the patch
cd
cd ffmpeg
wget --no-check-certificate https://roundup.ffmpeg.org/file831/ffmpeg-lame-flush.patch3
  1. Apply the patch
patch < ffmpeg-lame-flush.patch3
## (when the file name is required enter: libavcodec/libmp3lame.c)
  1. Build and install ffmpeg again
make
sudo checkinstall --pkgname=ffmpeg --pkgversion "4:SVN-r`LANG=C svn info | \
    grep Revision | awk '{ print $NF }'`" --backup=no --deldoc=yes --fstrans=no \
    --default

And now you’re ready to go!