YoLinux: Linux MP3


This tutorial covers the generation of MP3 files for use with audio streaming (IceCast) or for use in MP3 players. This tutorial will cover the use of the Grip GUI tool as well as the command line interfaces used to generate MP3 files.

Creating MP3 files from a CD: - Using the GUI tool Grip -

Grip is available in RPM form with the current Fedora Core and Red Hat distributions. On older Red Hat 7 releases, it was available on the Red Hat Powertools CD The source is available from the Grip home page. This GUI is a (beautiful) front-end to Linux command line tools. It utilizes cdparanoia (cdparanoia is actually built into Grip or you can use the external cdparanoia command) or cdda2wav (my choice) for CD "ripping" and lame (best choice), bladeenc, mp3encode, gogo, xingmp3enc or l3enc to encode the MP3 file. Set the appropriate options under the "Config" tab. Grip also has a built-in CD player (GCD) and connects to CDDB (freedb.freedb.org) to obtain track titles where available.

Usage:

Note: Grip will also generate a playlist (.m3u file) of the tracks converted and put it in your $HOME/mp3/ directory.

Configure Select Tracks Rip



Free Information Technology Magazine Subscriptions and Document Downloads


Creating MP3 files from a CD: - Using the command line -

It is easiest to use the GUI tool Grip as described above. You may choose to use the command line interface as detailed here:

Dump tracks on an audio CD to wav files on your hard drive:

cdda2wav -D 0,4,0 -B /tmp/prefix-of-music-file
          
The files will be written out as /tmp/prefix-of-music-file_01.inf /tmp/prefix-of-music-file_01.wav /tmp/prefix-of-music-file_02.inf ...

You may have to be root. See YoLinux managing groups tutorial to configure system for regular users with CD-ROM access.

Encode MP3: Convert WAV to MP3

Use one of the following encoders:

  • Lame:
    lame prefix-of-music-file_01.wav  song.mp3          - Fixed 128kbs stereo encoding
    lame -h prefix-of-music-file_01.wav  song.mp3       - High quality
    lame -f prefix-of-music-file_01.wav  song.mp3       - Fast and low quality
    lame -b 112 prefix-of-music-file_01.wav  song.mp3   - Encode at a bit rate of 112 kbs
                  
    Type lame --help or see file "USAGE" to get list of options.

    Use mlame script to convert multiple wav files.
    ./mlame -r -o "-v -V 0 -b 112" a*.wav

    mlame Options:

    • -h: help text
    • -r: remove files after encoding
    • -o: "<lame options$gt;" overrides script default options "-h -d -m j -b 128"

    OR

  • Bladeenc:
    bladeenc prefix-of-music-file_01.wav  song.mp3

Note: The size of the MP3 file will be approximately 10% the size of the wav file.


MP3 encoders

I was e-mailed the following tip: "Found that the BladeEnc MP3 encoder works better (for my ears) encoding NewAge/Classical/etc and that lame is better for harder music genres." Judge for yourself.

One may notice that the MP3 encoders are often missing from Linux distributions. The reason is that since 1998, the German research lab that holds the MP3 patent, Fraunhofer, began imposing a fee of $15,000.00 plus $5.00 per encoder and 50 cents per player sold or distributed. [Ref. Wired magazine Sept. 2001, pg 74 article by Pete Rojas] This may lead to the eventual rise of Ogg Vorbis as a standard format although the recording industry rejects it due to the lack of anti-piracy mechanisms.


Building Lame: (MP3 encoder)

The "lame" command line MP3 encoder is used in the conversion of wav files (and other formats) to the MP3 file format.

The "lame" encoder RPMs currently ships with the Fedora Core. If you wish to build the latest:

  • The Lame home page: http://www.mp3dev.org/mp3/
  • Download from SourceForge
  • tar -xzf lame3.70.tar.gz (Don't get their beta versions. I tried and it didn't even compile!!)
  • cd lame-3.70
  • make (Beta versions used ./configure but version 3.70 just had a make file)
  • mv lame /opt/bin
  • mv mlame /opt/bin (Script to handle multiple files)
  • mv auenc /opt/bin (Script to handle multiple files)
  • mv doc/man/lame.1 /opt/man/man1
  • mv doc/html /usr/doc/lame3.70 (Red Hat 6.x doc location)
    or
    mv doc/html /usr/share/doc/lame3.70 (Red Hat 7.x doc location)


Building BladeEnc: (MP3 encoder)

The "bladeenc" command line MP3 encoder is used in the conversion of wav files to the MP3 file format.

  • Download source from the BladeEnc home page: http://bladeenc.mp3.no/
  • Click on "Sourcecode" (left frame)
  • tar -xzf bladeenc-0.9x.x-src-stable.tar.gz
  • cd bladeenc-0.9x.x
  • ./configure --prefix=/opt
  • make
  • make install


Playing MP3 files:

Xmms Player:

  • xmms file-a.mp3

Typing the letter 'l' will open a dialog box which will allow you to select a new file.

Xmms Home Page
Xmms plug-ins - additional List of XMMS plug-ins.

FreeAmp Player:

  • freeamp file-a.mp3


Links:

Players:

  • MP3: Xaudio, xmms, mp3blaster review
  • MP3 Player review
  • XMMS.org - 4Front Multimedia
  • MPG123 - Console MP3 player
  • MP3 Tools lists
  • MusicMatch.com: Jukebox 7.0 - MP3 player, encoder (Fraunhofer), CD ripper, CD burner, line-in encoder, CDDB integration, Jukebox MP3 player/manager,... Commercial software for purchase. Reportedly handles streaming MP3 but it did not work for me. Menu tip: left click on menu bar then right click and hold to select item. Can create MP3's at 44kHz/128kbps to 160 bps. Relies on Wine libraries. (installed and configured as part of install) MPEG URL handler/launcher for Netscape did not work for me.

Encoders:

Other Links:


Return to http://YoLinux.com for more Linux links, information and tutorials
Return to YoLinux Tutorial Index
Feedback Form

Copyright © 2001, 2002 by Greg Ippolito