Reflections of a middle-aged geek

Add MP3 support to Audacity on Fedora

No doubt that MP3 is the most popular audio format out there, so it’s only natural that most users expect that any software which deals with audio files has MP3 support built in. However not all MP3 patents have expired in some countries, therefore some Linux distributions don’t provide MP3 codecs out of the box because they violate their policies.

Recently I had to edit a personal MP3 file, so after a quick research I decided to install Audacity which is available at Fedora‘s repository. However, as soon as I tried to open that MP3 file in Audacity, I discovered that it wasn’t compiled with MP3 support (due to the reasons that I explained above):

RPM Fusion‘s free repository contains a package called audacity-freeworld that comes with FFmpeg enabled, so you can use it to work with MP3 and other proprietary audio formats, but just for fun I decided to recompile Fedora’s Audacity with MP3 support myself, after all, that’s the beauty of open-source software. Besides, what else to do on a Friday night when all my family was already in bed? 🙂

This article describes how to do that, therefore if you need/want to add MP3 support to Audacity just keep reading. All this was tested on a Fedora 23 Workstation.

I could do this in a few different ways, but I picked what I believe was the easiest one, which basically meant that I would have to:

Prepare my computer to build a RPM

Download Audacity’s source RPM (SRPM) from Fedora’s repository

Build a new RPM for Audacity with MP3 support somehow

Install the new RPM and test it

Keep in mind that for commercial (i.e. revenue-generating) use you may need to pay royalties for using MP3 software, but there are patent-free alternatives to MP3, like Ogg Vorbis, that you might want to consider.

Preparing the computer to build SRPMs

This needs to be done only once, so if you have already done this on your computer then you don’t need to do it again.

Fedora’s wiki has a lot of information about how to create a RPM package, but since you are not going to create a RPM package from scratch (you’re just going to recompile one official SRPM for your personal use) the process is a lot simpler: no need to run rpmlint, mock, manage GPG keys and signatures, etc.

First of all you must be root before you can execute the following steps. To become root you just need to open up a terminal and type the following command:

$ su -

Then you will be asked for the root’s password. After that, let’s make sure you have all the software that is needed. Just type the following command line:

# dnf -y install rpmdevtools mock @c-development

It’s generally a bad idea to build RPMs as root because you might accidentally pollute or even damage your system, therefore we need to create a new non-privileged user just to do that. Simply run the following commands:

# useradd -G mock mockbuild
# passwd mockbuild

The two command lines above will create the user mockbuild on your system, add it to the mock group and ask you to define a password for it. Type any password you want, preferably one that is long and complex enough but still you can remember it (TIP: use six words from Diceware™).

Since this new user will only be used to build RPMs, it’s likely that you don’t want to see it listed in GDM‘s login screen. In order to hide it from that screen you need to create the file /var/lib/AccountsService/users/mockbuild with the following two lines in it:

[User]
SystemAccount=true

Ok, so now that the user was created you have to make sure that the directory structure required to build a RPM package is in place. Just execute the following command: