Creating MP3 or Ogg Vorbis Files

In the past, people have used a variety of media and formats for storing music—LP records, cassette tapes, and audio CDs being three of the most popular. Since the late 1990s, a new class of formats has emerged: compressed digital audio files, which can be stored on a variety of media for different players. Several specific file formats have emerged to fill this role, but one of the most popular is the Moving Picture Experts Group Layer 3 (MP3) format. A wide variety of hardware and software, ranging from dedicated portable MP3 players such as the popular Rio to MP3-enabled CD players to software multimedia players such as those described in the next section, "Using a Multimedia Player," can handle MP3 files. A simpler but related format, MP2, is also available.

One problem with MP3 is that the algorithms used to manage MP3 compression are covered by patents, so creating and using MP3 files can be a legal minefield for open source software. For this reason, many Linux users prefer using a competing file format, Ogg Vorbis (http://www.vorbis.com). Unfortunately, although Ogg Vorbis is a perfectly good format for computer-only use, portable Ogg Vorbis players similar to the Rio are rare, at least as of early 2003.

Both MP3 and Ogg Vorbis are lossy compression schemes, which means that they throw away some of the input data. Lossy compression is useless for storing program files, database files, and so on, but it can be very useful when applied to graphics, sound, or multimedia files—the compression scheme can be designed to throw away data that humans are unlikely to notice. Lossy compression schemes, including MP3 and Ogg Vorbis, typically enable you to set a level of compression. Low compression reproduces the input well enough that you're unlikely to object to the compression artifacts. High compression throws away more data, so even with good compression algorithms, you're likely to notice the effect.

Many Linux programs to create MP3 and Ogg Vorbis files exist; some of the more popular include:

lame This program may be the most popular MP3 encoder for Linux. It's headquartered at http://lame.sourceforge.net. Because it is open source software, using it in the United States and other countries in which patents on MP3 algorithms are valid requires a special license, which is impossible for individuals to obtain.

mp3enc This is a commercial MP3 encoder for Linux. A demonstration version is available from

http://www.iis.fraunhofer.de/amm/download/index.html.

toolame This program, headquartered at http://toolame.sourceforge.net/, is an MP2 encoder.

oggenc If you don't need to play your files on portable MP3 players, MP3-enabled CD players, and the like, you can create Ogg Vorbis files with oggenc, which is based at http://www.vorbis.com.

Each of these programs has its own syntax and quirks, so you should consult your program's documentation for details on how to use it. Most provide a large number of options to encode information such as the album title, track title, performer, and date in the output data file. You can also set options that affect how the lossy compression scheme works, including one or more methods of setting compression rates and options to enable or disable particular compression features. As an example of one of these tools in use, consider the following command, which creates an Ogg Vorbis file from a standard .wav file:

$ oggenc -a "Linus Torvalds" -t "Linux" english.wav

This example converts a file called english.wav to english.ogg, adding information to the file specifying the title as Linux and the performer as Linus Torvalds. Similar commands can convert other audio files. Of course, you must have an audio file before you can convert it. In practice, chances are you'll want to encode an audio file derived from an audio CD, in order to convert the CD for playback on your computer or using a portable MP3 player. To do this, you must use a digital audio extraction

(DAE, aka a CD ripping) tool, such as Cdda2wav (http://www.escape.de/users/colossus/cdda2wav.html) orcdparanoia (http://www.xiph.org/paranoia/). Like the MP3 and Ogg Vorbis encoders, these are command-line tools. In most cases, use of cdparanoia is simple: Type its name followed by the track or tracks you want to extract (enclosing them in quotes will protect them from being mangled by the shell). Some systems require that you have root privileges to run cdparanoia, even if you own the relevant device files. An example of cdparanoia in use is:

$ cdparanoia "1-4"

Warning In most countries, including the United States, performing DAE is legal, but only for personal use. For instance, you can create a backup CD, copy tracks to a personal MP3 player, or the like. It's not legal to distribute extracted files.

For extracting anything more than one or two isolated tracks, chances are you'll want to use a GUI front-end to a DAE and compression tool. One very popular front-end is Grip (http://www.nostatic.org/grip/). This program includes cdparanoia code compiled into its binary, but it can use Cdda2wav or another DAE tool if you prefer. It requires an external encoder, such as oggenc, to do encoding. When you launch Grip and insert a CD, it reads the CD's contents and tries to identify it using an online database (atfreedb.freedb.org, by default). If this operation is successful, Grip displays the CD's title, performer, and track titles, as shown in Figure 8.2. If not, track numbers are displayed. In either case, you can edit track titles and artist names by clicking the disc editor button in the main window (it resembles a pencil, near the middle of the bottom row of icons). The first time you run Grip, you may need to configure it from the Config tab, which in turn presents several sub-tabs. Of particular interest, the CD sub-tab enables you to specify what device to use to read CDs, the Rip sub-tab tells Grip what program to use for DAE functions, and the MP3 sub-tab configures the MP3 or Ogg Vorbis encoding software.

Figure 8.2: Grip is a powerful and popular MP3 and Ogg Vorbis encoder front-end.

To create MP3 or Ogg Vorbis files, right-click the titles you want to encode, click the Rip tab, and click the Rip+Encode button. This will do the job, but you must have a fair amount of space available on your disk—potentially a gigabyte or so, depending on the speed of your CD-ROM drive at DAE and the speed of your CPU for encoding.

Note Most computer CD-ROM drives aren't optimized for DAE, and some won't do DAE at all. Most take longer to perform DAE than they'd take to play the audio CD as such. Ripping and encoding a single CD can take several hours, even on a fast computer.

0 0

Post a comment