Install an MP3 encoder on Linux

Adam Satterwhite wrote in saying he needs to buy an MP3 player to use at work, in order to maintain his sanity during an eight hour shift. However, all the players in his price range only play MP3 or other proprietary music file formats. All of his music files are already stored in Ogg Vorbis format on his Linux system, which doesn’t support MP3. His problems involve not being able to change all of the Ogg Vorbis files into MP3s, and he doesn’t know how large and what type of player he needs to buy.
If quality is your priority, Adam, go back to your CDs and save the MP3 files that your system will create for you. But you won’t be able to do this unless you can save files in MP3 format. You’ll have to install a program that will encode to MP3. As MP3 is a proprietary format and not included with Linux distributions, you’ll have to download the program (or the source) and compile it yourself.
LAME
The oddly named LAME will encode WAV format files to MP3, but first you need to get a copy. You’ll find that almost all of the pre-compiled versions are for Windows or a specific Linux distribution, which we would recommend you try first. If the precompiled version doesn’t work on your distribution, it’s fairly straightforward to compile your own.
Firstly, you need to download the source, so go here . Click on the ‘important message from the RIAA’ link and read it. Then go back and click on the ‘Source Code: Click here…’ link and the 3.96.1 (or higher) link that ends with ‘.tar.gz’, which will take you to the SourceForge.net download server. Choose a mirror and click on the download link. The .tar.gz should be saved to your normal directory.
The following is fine if you’re using a windows manager such as KDE. Right-click on the .tar.gz and, in the drop-down menu, select ‘Ark’ or Open with… | Utilities | Ark. In Ark, you’ll see a list of all of the files and directories in the archive. Click on Action | Extract… and choose somewhere to extract the files. Click on ‘OK’ and close Ark. Open up Konqueror at the location where you saved the extracted archive and then, in the pane with all of the files in it, right-click on a blank area. On the menu, click on ‘Open Terminal Here’. Next, at the command prompt, type the following: This will configure, compile and install the program. This isn’t instant, but at the end of it, you’ll have the MP3 encoder compiled for your own system rather than have a generalised version of it that may have system specific incompatibilities within it.
./configure
make
make install
ogg2mp3
Now that you have your MP3 encoder, you need to have a program that will take your OGG files and convert them to MP3. Usually, if you want to perform a conversion from one format to another, you can find a program with a name made up of the two file extensions with the number two between. A quick look on Google shows a program (a Perl script by Mark Draheim) called ogg2mp3, found here which has a download halfway down the page (Files… Just the script).
Save the script somewhere on your system. The root directory where you keep your OGG files will make the following easier, and make sure that it is executable. When you’ve done this, open up a command shell at that location and type: If all has gone according to plan, it will start recursively munching its way through your directories of OGG files, translating them to the same filename but with the MP3 extension.
./ogg2mp3 *
However, you’ll probably find that you need to do more first, and the clues are in the ogg2mp3 program script. If you open it up in KWrite or Kate, you’ll see that there are a number of things that need to be present. The files ‘ogginfo’ and ‘ogg123’ need to be in ‘/usr/bin/’, which they already should be, as you’ve generated your own OGG files, and you need to make sure that LAME, which you’ve just compiled, is also in ‘/usr/bin/’. Alternatively, you can alter the line in the Perl script that tells the script where to expect to find it. If you’re missing a Perl module, have a look at the sidebar on the next page.
With all of the locations correct, and with the correct modules installed, ogg2mp3 will now work away recursively (though not necessarily in what we may think is a logical order) until they’re all converted. If you have a fairly extensive collection, you may want to think more about spending the time you’ll have to wait preparing an elaborate four-course meal, rather than swiftly nipping off to make a quick cup of coffee.
Once it’s finished though, you’ll have an MP3 and OGG copy of every single song in your directories. To make using your MP3 player easier, it’s better to have the MP3 files in a separate directory, so if you have OGG and MP3 directories with all of the album directories within those, you can use them far more easily. Using the MP3 player is now just a matter of doing the following: plug the player into the USB port, mount it (usually as sda1 or similar), open up Konqueror, delete any files or directories that you don’t want and copy any new ones across. Then unmount the USB and unplug it.
One thing to be aware of is that USB MP3 players are effectively flash disks and, as such, use ‘vfat’ (FAT) as the file system (this is so they’ll work with Windows machines). The only problem you’re likely to encounter with this is if you use camel notation for otherwise identical filenames, so ‘NotHere’ and ‘NoThere’ will be the same under vfat.
CD to MP3
Now you have your MP3 encoder, you can use Konqueror’s ‘Services’ menu. Click on the ‘Services’ icon and you’ll see the CD options available. If you click on MP3, you can highlight the tracks you want, drag them into a directory in another copy of Konqueror, and the encoder will convert the CD’s tracks for you (the same will happen with Ogg Vorbis). In this way, you can create new OGG and MP3 files from CDs that you purchase.
At the beginning, we said that it was best to create MP3 files from the CD. The reason for this is that Ogg Vorbis is a lossy compression algorithm, in the same way that MP3 is a lossy compression algorithm. Each algorithm throws away different parts of the data in order to get the compression that it needs, but the reason you shouldn’t go from one to the other (in either direction) is that they throw away different parts.
By compressing to Ogg Vorbis, you throw away some data, but by converting it to MP3, you decompress it and throw away some more data. You can never get back the data that was thrown away by the first compression algorithm that you used. However, for a personal MP3 player, quality isn’t really the pressing issue.
Choosing the right MP3 player is not just about size.
The question of which MP3 player to buy is still outstanding. The main issues you’ll probably want to consider are size and the types of files the player can read. First of all, size. For an eight hour shift, you’re going to need about 400MB of space. But remember, you’ll now have the luxury of being able to delete and copy any selection you like, so changing the songs that you listen to will be a lot easier than before. The drives that are available tend to go up in multiples of two, so a 512MB MP3 player will have plenty of space.
If you’re planning to get a 1GB or even a 2GB MP3 player, one thing in its favour is that when you turn them back on, they remember where you left off, so you don’t have to scroll through hundreds of tracks trying to find one that you haven’t listened to recently.
One word of warning, though, is that when the battery runs out (this is now one of those technologies where everything has become so small that even the single AAA-sized battery weighs almost as much as the rest of it), it only remembers where it was when it was last switched off, which could be as much as six hours ago.
File types are another matter entirely. Each time a music vendor sells an MP3 track, they’re responsible for paying Fraunhofer a percentage of each sale in return for them using their patents. Ogg Vorbis is patent and licence-free and, as the quality for a given file size/bit rate is demonstrably better, it’s only natural for music vendors to move over to OGG files given time. Therefore, you will undoubtedly be better off if you invest in an MP3 player that can have its firmware updated.
Apart from getting superior quality with Ogg Vorbis, you’ll also be able to get more music on there and, if you buy music online, there’s the potential for the savings in licensing to then be passed on to the purchaser (but don’t hold your breath).

