Building a Linux Media Network, one step at a time

Friday, June 16, 2006

SuSE 10.0: MP3 Support in K3B for Beginners

Hey! In the words of the immortal Jim Anchower, I know it's been a while since I rapped at ya. This entry is going to take a bit of a detour from the Media Center setup. Instead I'll talk about building functionality into your Linux OS based on a combination of package management and good-old-fashioned building from open source.

This article is targeted more towards open-source beginners... if you've been following along with the rest of the stuff on this site, you've probably already progressed beyond this point. In any event, I welcome your comments.

SuSE Linux, by default, does not ship with MP3 support for many of its applications. I'm not sure if this is because they would be forced to license such technology from the patent-holders of the MP3 encoding algorithm, or if the RIAA prevents it somehow. Anyways, it's a pain in the ass. For instance, K3B, the popular CD-burning software for the K Desktop Environment (KDE), is pretty much crippled for making audio CDs. Fortunately, it's pretty simple to rebuild K3B and include MP3 support.

I shouldn't say simple. The process itself is actually fairly complex, with dozens of different software products interacting with each other. But the trick is to use the right tools to make it simple.

Every Linux distribution these days, as far as I know, comes with some sort of package management software. This tool's job is to resolve all these interactions and interdependencies between various software packages. In SuSE, the distro I'll be covering here, this tool is called YAST. In Debian or a debian-based distro such as Ubuntu, it's called apt-get. In GenToo I believe it's called emerge. Point is, whatever distribution you've chosen, there will almost certainly be a tool available to help you with this process.

I should say right up front: if your distro hasn't got one, or you can't find it, stop now. In the time it takes you to resolve all the dependencies for building K3B you can install Ubuntu and never have to worry about this again.

SuSE 10.0 Specific Note


You can make these package installs go a lot faster if you (a) have a copy of the original installation media and (b) have some hard drive space to spare. What I did was create a directory, /suse10dvd/CD1, and copied the entire file/directory structure from my SuSE DVD into that directory. Then, in YAST, you create a new installation source from the directory /suse10dvd (it will automatically look in CD1 for all the requisite files).

Setup the development tools


Eventually, all the package management in the world is only going to get us so far. When we reach that point we're going to need to take source code and turn it into a binary executable. And to do that we will need some tools. Fortunately, these tools can be installed by - you guessed it - the package management system. Again, I will be assuming you're using SuSE 10.0 here. As root, fire up YAST, and click on Software Management (might as well keep that screen open for a while).

Install the following packages: gcc g++ make automake autoconf. Accept any dependencies YAST points out.

Setup K3B source prerequisites


All these packages are also installable via YAST. Go ahead and install them now: xorg-x11-devel zlib-devel qt-devel libjpeg-devel kdebase3-devel taglib-devel libmusicbrainz-devel

If you notice that you're installing one of these "devel" packages, but the corresponding package is not selected (ie. libjpeg for libjpeg-devel), go ahead and select that too. That's a lot of stuff, and it'll probably take a while to install. While it's working you can download some of the stuff we'll need that SuSE can't provide.

Getting the source prerequisites


You'll need to get the source code for libmad. This provides K3B with the ability to decode MPEG audio (ie. what we commonly refer to as an mp3 file). Get it here. Use SourceForge or their FTP site, doesn't matter. You don't need the id3tag or madplay stuff, just the libmad download.

You can build a more complete K3B by downloading LAME from lame.sourceforge.net. LAME (Lame Ain't an MP3 Encoder) allows K3B and other tools to encode audio into MP3 format. This isn't necessary for what we want to do, but it will add valuable functionality to your SuSE installation.

These source packages come in a .tar.gz format - commonly known as a tarball. Once you've downloaded them to a convenient spot on your hard disk you can extract them with the "tar xvfz <source package>.tar.gz" command.

Extracting one of these tarballs will create a directory holding the source code, ie. lame-3.97. Once you're in this directory you can build the executable from the source code using these three commands - they're the same for pretty much any open source software package:

  1. ./configure

  2. make

  3. (as root) make install


The first command ensures that all the necessary dependencies are available and sets up the eventual install paths. The second command actually takes the source code and turns it into binary files - executable files, code libraries, etc. The third command takes those output files and puts them in the proper locations so that other programs (ie. k3b) can find them.

I should note that the configure script takes a lot of options. You can see some of them by running ./configure --help. Unless you see something that really jumps out at you, you should accept the defaults for this project.

Make sure that you run the last command, make install, as either the root user or someone with root-like permissions. Otherwise you probably won't be able to put the generated files in the default spots.

Building K3B


Is basically a non-event. Download the K3B source tarball from the K3B homepage. Extract it just like you did with the prerequisites (note that if the file ends in a .tar.bz2 suffix, you should use the command tar xvfj <filename>.tar.bz2 rather than tar xvfz. Go into the newly-created directory and run the same ./configure,make,make install commands as above.

Note that when you run the configure script, it will show you which extra features will be built into K3B. You should see something like this:

K3b Configure results:
------------------------------------------
Ogg Vorbis support: yes

Mp3 decoding support (libmad): yes

Audio meta data reading with Taglib: yes

libsndfile audio decoding support: yes

FLAC support: no
You are missing the FLAC++ headers and libraries.
The FLAC decoding plugin won't be compiled.

Musepack support: no
You are missing the Musepack headers and libraries >= 1.1.
The Musepack audio decoding plugin won't be compiled.

Lame Mp3 encoder plugin: yes

Audio resampling:
using version bundled with K3b

FFMpeg decoder plugin (decodes wma and others):
no
You are missing the ffmpeg headers and libraries
version 0.4.9 or higher.
The ffmpeg audio decoding plugin (decodes wma and
others) won't be compiled.

Resmgr support: yes

Audioplayer available (aRts) yes

Compile K3bSetup 2: yes

Tag guessing using MusicBrainz no
You are missing the musicbrainz headers and libraries.
K3b will be compiled without support for tag guessing.

Compile HAL support no
You are missing the HAL >= 0.4 headers and libraries
or the DBus Qt bindings.


Good - your configure finished. Start make now


Your new version of K3B will by default be installed right overtop of the old version. This is convenient, but you must remember now that the package manager (YAST) doesn't know that you've swapped in this new version, so any updates that SuSE may try to apply will probably blow away your changes. Careful!

If you'd rather put K3B in a different place, use the --prefix argument to configure. Again, configure --help has more information.

That should be it! If you can drag MP3 files into your Audio CD project, you'll know everything's working. Double check via the Help Menu that the version of K3B that you're running corresponds to the version that you just built - you may be running the old executable.

If you have any trouble, Google is your friend. If you're still in trouble, my contact information is on the sidebar to the right of this page.

Good luck!