FFmpeg with MP3 encoding support on Debian

Due to legal issues Debian does not contain the necessary libmp3lame libraries that ffmpeg depends on for encoding MP3 files. However you've a couple of options to get around this issue.

  • RareWares.org provides a Debian repository that you can include in your apt.sources file and install the necessary libraries from there. You should use the unstable branch since it contains quite recent LAME libraries (3.96, 3.97 and 4.0 are all available).
  • You can compile you're own LAME libs quite easily.
I'll go into detail on the latter one. To make life easier, I did not create a debian package from scratch for the LAME libs, but instead used Ubuntu's packages and compiled them on the Debian server. If you've an Ubuntu server at hand, then just download the sources:
apt-get -d source liblame-dev

If you've no Ubuntu nearby, you'll have to manually download the required bundles (*.tar.gz, diffs, etc.) and apply all the patches.

In the end you'll have a lame-3.97 (or similiar) directory with the recent (already patched) version of the source. Copy this to your Debian server and compile the package. But first you need to get the packages that are required for building the libs. Take a look at the debian/control file in the LAME sources directory and look for the line starting with Build-Depends:. You've to install the packages you find there on your Debian server:
apt-get install debhelper libgtk1.2-dev libncurses5-dev nasm

You've to install the fakeroot package too since it'll be required in the packaging process. Or you can skip it if you're building as root.

Now comes the building (you should enter the LAME sources dir first):
dpkg-buildpackage -rfakeroot -uc -b

This'll produce four packages (.deb files) in the parent dir of the LAME sources directory:
  • lame
  • lame-extras
  • liblame0
  • liblame-dev
For ffmpeg we need only the latter two. So let's install them:
dpkg -i liblame0_3.97-0.0_i386.deb liblame-dev_3.97-0.0_i386.deb

Now we can compile our ffmpeg. First fetch the sources:
apt-get source ffmpeg

We've to make a few changes to the Debian package files. Add the --enable-mp3lame option to the confflags variable in debian/rules. Like this:
confflags += --enable-gpl --enable-pp --enable-pthreads
confflags += --enable-vorbis --enable-libogg --enable-a52 --enable-dts --enable-libgsm --enable-mp3lame

Now add the liblame-dev package to ffmpeg's dependencies in debian/control:
Package: ffmpeg
Section: graphics
Architecture: any
Depends: ${shlibs:Depends}, liblame-dev

You can also add your own entry to the changelog (in debian/changelog) in case you want to have your own version number for the package.

Now in the ffmpeg source dir start the package build process:
dpkg-buildpackage -rfakeroot -uc -b

This created a number of DEBs in the parent dir. The ffmpeg package depends on libavcodec0d and libavformat0d. These were also built now and it is crucial that you install these custom builds and not the ones from the APT repository (remove them if they are already installed from APT). Otherwise your mp3 encoding support will not work.

After you installed all your custom packages, you're ready.

PS: to make sure that an apt-get upgrade does not ruin your efforts by overwriting your packages with newer versions from your repositories, you should use dpkg --set-selections to keep your own packages on hold.
echo "ffmpeg hold
liblame0 hold
liblame-dev hold
libavcodec0d hold
libavformat0d hold" | dpkg --set-selections

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

mpeg4 support via XviD (libxvidcore4) for ffmpeg

You can add mpeg4 encoding support to ffmpeg by using the --enable-xvid option with configure (or in debian/rules if you're building a package). However you'll need the libxvidcore-dev package for that. Debian does not have it, but Ubuntu does (again Smile ). So you can apply the same method for creating a libxvidcore4-dev package for Debian as I described in the post for the LAME libraries. Of course you'll need other build dependencies for this one, namely debhelper, yasm and dpatch.

Fixing FFmpeg on Ubuntu

The article at https://wiki.ubuntu.com/ffmpeg describes the compile of a custom ffmpeg package (with all the goodies) pretty well. You should probably take a first look at that one (seems to be a lot more easier and lightweight) before going into the depth with my article.