MP3

Technical Information
MPEG files comes in different flavours. We shall focus on MPEG audio.

MPEG
Moving Picture Experts Group (MPEG) is a family of standards for coding audio-visual information in a digital compressed format. The MPEG family of standards includes:


 * MPEG-1 (ISO/IEC-11172) Coding of Moving Pictures and Associated Audio for Digital Storage Media at up to about 1.5 MBit/s. MPEG-1 supports MPEG audio layer 3.
 * MPEG-2 (ISO/IEC-13818) Generic Coding of Moving Pictures and Associated Audio. MPEG-2 supports and extends MPEG-1 Audio, but it also supports Advanced Audio Coding (AAC) which is a more flexible and overall better coding than MPEG audio layer 3. There is even a lossless variant, MPEG-4 SLS.
 * MPEG-4 (ISO/IEC-14496) Very Low Bitrate Audio-Visual Coding. MPEG-4 also supports AAC.

MPEG-3 doesn't exist, it has been merged into MPEG-2.

Layers
MPEG Layers are coding schemes. There are 3:


 * MP1 or MPEG-1 Part 3 Layer 1 (MPEG-1 Audio Layer 1)
 * MP2 or MPEG-1 Part 3 Layer 2 (MPEG-1 Audio Layer 2)
 * MP3 or MPEG-1 Part 3 Layer 3 (MPEG-1 Audio Layer 3)

with increasing efficiency and complexity. Furthermore, each layer implements the previous layers.

So, MP3 files are MPEG-1 Part 3 Layer 3 files.

And now the plot thickens: the MPEG-2 standard also supports MP3 audio, but extends the number of possible bit- and samplerates. And just add salt to the wound, Fraunhofer Institut Integrierte Schaltungen has implemented a non-ISO variant, referred to as MPEG-2.5, with even more possible variations. The possible bit- and samplerates are listed here (output from ):

* MPEG-1  layer III sample frequencies (kHz):  32  48  44.1 bitrates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320 * MPEG-2  layer III sample frequencies (kHz):  16  24  22.05 bitrates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160 * MPEG-2.5 layer III sample frequencies (kHz):  8  12  11.025 bitrates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160

Rationale
First, I used iTunes for encoding to MP3. It could encode to 192 kbps, which was what I wanted. The resulting audio was near-perfect for listening on my iPod. But iTunes is too restrictive: you cannot copy music from your iPod to the computer with it.

So, I wanted another solution: LAME.

Lame has a nice Windows frontend: winLAME.

Installation
is the MPEG encoder,  is an ID3 tag editing tool.
 * 1) emerge lame id3v2

Usage
Convert a flac file into a Constant Bit Rate (CBR) 192kbps MP3


 * 1) flac -dc 04-Gravity_rearrangin.flac | lame -b192 - >"Gravity Rearrangin.mp3"

Convert a flac file into a Variable Bit Rate (VBR) file with good quality


 * 1) flac -dc 04-Gravity_rearrangin.flac | lame --preset extreme - >"Gravity Rearrangin.mp3"

Convert all the flac files in a directory into iPod-friendly format MP3 files in the current directory. The iPod cannot read VBR MP3s. Set ID3 tags.

path=BryanFerry/Mamouna/ outputpath="../MP3/Bryan Ferry/Mamouna/" for f in `find $path -name "*.flac" -maxdepth 1 -printf "%f\n"`; do         tracknumber=`echo $f|egrep -o "^[0-9]+"` filename=`echo $f|sed -r -e "s/\.flac$/\.mp3/g" -e "s/_/ /g" -e "s/^[0-9]+-//g"` trackname=`echo $f|sed -r -e "s/\.flac$//g" -e "s/_/ /g" -e "s/^[0-9]+-//g"` echo "==== trackname: '$trackname' tracknumber: '$tracknumber' output: '$outputpath$filename'" flac -dc $path$f | \ lame -b192 --ta "Bryan Ferry" --tl "Mamouna" --ty "1994" --tg "Rock" \ --tt "$trackname" --tn $tracknumber - >"$outputpath$filename" done

Or use the evil one-liner from hell:

$ find -regex ".*\.flac$" -printf "%P\n"| awk '{ new = gensub(/flac/, "mp3", "g", $0); printf("flac -dc \\\"%s\\\" | lame -b192 - \\\"%s\\\"\n", $0, new); }'| xargs -i bash -c "{}"

$ find -regex ".*\.flac$" -printf "%P\n" |                                <- find all .flac files awk '{ new = gensub(/flac/, "mp3", "g", $0);                               <- create a .mp3 filename printf("flac -dc \\\"%s\\\" | lame -b192 - \\\"%s\\\"\n", $0, new); <- create command }' | xargs -i bash -c "{}"

ID3 Tags
The ID3v1 tags are horrible in every way. They are included as the last 128 bytes of a MP3 file, making the parsing of them slow. All the data of the tags are limited to 30 characters. And we haven't even discussed the worst of it yet.

So - use ID3v2 instead. Se my article on Encoding for example usage.

Mad Ravings About the ID3v1 Genre Tag
Some genius named Eric Kemp had a bright idea:
 * "MP3 files should have a genre tag. How many music genres can there be? I guess 100 is enough. I'll define them, because I know everything about music"

And then he creates a list of genres, including many usable ones, such as Rock, Pop, Classical, enabling us to broadly define the area of music a particular track belongs to. That's fine. But a lot of numbers were left unused. What does Eric Kemp, the omniscient music scientist, do? The pinhead adds obscure genres like:
 * Fast Fusion, National Folk, Acid Punk, Lo-Fi, Psychadelic, Christian Rap, Darkwave, Space, Ska

I believe some of these genres existed for about 17 minutes one day in 1993, and I'm pretty sure "Psychadelic" and "Fast Fusion" never existed at all. Furthermore, I won't think "Christian Rap" ever will be a big hit... But who knows?

Of course, he had never heard of genres such as:

(if you can't tell, I'm being sarcastic :)
 * Opera - too bad for Mozart, Verdi, etc. - who listens to opera, anyway?
 * Heavy Metal - he has Death Metal, and it's all the same, right?
 * Samba - Latin America? What's that?
 * Drum & Bass - but he has Christian Rap, and that has been much more influential over the ages...

To complete the travesty, WinAmp (an otherwise good program) extended the standard with the above mentioned genres, but also added new genres, like:


 * JPop, Terror - ?
 * Rhytmic Soul - as opposed to Ambient Soul, I guess. I wish they could spell 'rhythmic' right, at least...
 * Slow Jam, Porn Groove, Booty Bass - these actually sound kind of cool - don't know what it is, though.
 * Primus - well, Primus is an original band, but their own genre?
 * Polsk Punk, Negerpunk - I mean: What the hell kind of crap is that?.

... and, of course, not to forget the Christian Rap blunder of the original format, a new genre called "Christian Gangsta" is added... Great stuff!