MP3: LAME EXE
*** Updated at 09/18/2001 ***
MP3 compression is probably the most popular format ever for sharing audio
over the Internet. MP3 has become so popular that manufacturers already started
making stand alone MP3 players so you can listen to your favorite MP3s even
without a computer nearby. The music industry tries to bring down MP3 as being
illegal which is absolutely not true! MP3 is here, and it is here to stay. That
is until a much better compression format arrives of course :)
In this part of the tutorial we will use the LAME external encoder.
Product: LAME
Author: Mark Taylor, Mike Cheng, Takehiro Tominiga, Robert Hegemann and other
developers
Homepage: http://www.mp3dev.org/
Platform: Windows 95/98/ME/NT/2000
Price: Open Source Freeware
|
Original
started as LAME Ain't an MP3 Encoder, a patch
to the ISO encoder to avoid legality issues with Fraunhofer LAME has evolved
to one of the best MP3 encoders available. In many tests LAME comes out as
best and surpasses Fraunhofer which has been the reference encoder for
years. At r3mix.net
you can find comparisons
& tests between LAME and other popular encoders. LAME comes out as the best and thus
is LAME
the preferred MP3 encoder if quality is your goal. LAME supports both
constant bitrate encoding and variable bitrate encoding, and is very fast
too. LAME is distributed as source code only, but some sites offer
compiled versions. The latest win32 compiled binaries can be found at Dmitry
Kutsanov's website.
LAME comes as an executable (EXE) and a Dynamic Linked Library (DLL). While
both give identical output, the executable version of LAME is preferred because
EAC has the ability to pass custom parameters to the executable allowing you to
make use of all of LAME's parameters. The DLL can only use a few predefined
settings.
Obtain the LAME external encoder
As said earlier LAME is distributed as source code. Now for most people
source code is useless, but you can get the latest win32 compiled binaries at Dmitry
Kutsanov's website.
At the moment of writing LAME 3.90 alpha is the latest r3mix.net
recommended version. Download LAME
3.90a. Check Dmitry
Kutsanov's website regularly for new updates of the encoder! The
latest 3.90 alpha version can be found under "alpha" versions and is contrary to
the stable versions not named with its version number, but with the compilation
date. For example lame-20010918 (09/18/2001). After downloading the zip
file, decompress lame.exe to your harddisk using WinZip
or similar. It's recommended to put lame.exe in the c:\windows\command
folder on a Windows 95/98/ME system, and c:\winnt\system32 on
Windows NT/2000 systems. Why? Files put in these directories can be accessed
from every directory on your system. Thus you don't have to change the path to
LAME's location every time you want to use it from the command prompt.
If you already had installed the LAME executable and want to find out its
version, open a command prompt and type lame, followed by a
press on the Enter key. Note that if you did not put LAME in
the above mentioned folders you'll have to set the path to lame.exe
first! The output of LAME should look like the screenshot below.
The version used in this example is thus LAME version 3.87 (beta 1, Sep 29 2000).
Configuring EAC for the LAME external encoder
Make sure you have Configured The Compression Options
in Exact Audio Copy.
From The EAC menu select Compression Options...
or press F11.
This opens the Compression options window.
|
On the External Compression tab, check Use external program for compression.
The settings on the Waveform tab have no influence and may
thus be ignored. From the Parameter passing scheme dropdown
box choose LAME MP3 Encoder.
In the Program, including path, used for compression field
enter the path to the LAME executable or use the Browse...
button to locate lame.exe
on your harddisk.
Enable the Delete WAV after compression checkbox. Exact
Audio Copy always extracts to WAV first when using an external compressor.
Enabling this option deletes this WAV file after it is compressed. It does not
make much sense to keep the WAV files after compression.
Use CRC check should be disabled. While LAME is one of the
few encoders which actually support the CRC check correctly it has little use.
Because most encoders' implementation of this feature is not working correctly,
most players ignore the CRC check. Besides that, enabling this option adds 16
bits (the CRC value) to every MP3 frame!
Enable Add ID3 tag if you want to take advantage of the
ID3 tag features. The ID3 tag saves extra information like artist name, track
title, album title into the MP3 file. The newer ID3v2 tag (which is also
supported by EAC - see Configuring The Compression Options)
can store even more extra information and gets rid of ID3v1's 30 characters
limitation.
The High quality and Low quality radio
buttons are defaulted to High quality, but we'll override
these settings so they have no effect.
|
Setting the LAME encoding options LAME
can be configured in EAC by selecting the bitrate from the Bit rate
drop down box. However, in this tutorial we will override these predefined
settings and use our own custom commands to get optimal control of the settings.
LAME supports virtually unlimited parameter combinations and it is not the goal
of this tutorial to test all combinations and determine which one gives the best
results. Luckily that's not necessary since other people already did this for
us. r3mix.net
is the place to be when it comes to MP3 encoder quality. r3mix.net
has done extensive tests with the LAME encoder and defined the optimal settings
for the best quality. These are the settings we will use in this tutorial too.
LAME supports both Constant Bitrate encoding (CBR) as Variable Bitrate encoding
(VBR). CBR encoding uses the same bitrate in every frame through the whole file.
VBR on the other hand changes the bitrate of every frame according to the
complexity of the audio data in that frame. Complex signals will force LAME to
use a higher bitrate, while simple signals force LAME to use a lower bitrate to
save space. VBR encoded files can have the same quality as a CBR encoded file
while the file size is a lot smaller. You can say that Variable Bitrate encoding
is the more efficient one. The drawback of Variable Bitrate encoding is that it
is way slower to encode, and not all players and decoders (correctly) support
it. Therefore, if file size is no issue for you avoid VBR and use Constant
Bitrate encoding instead. With the prices of storage media these days, file size
shouldn't be an issue for most people.
Important LAME parameters
In this small section I'll discuss the most important and common used LAME parameters. LAME has a
lot more parameters you can use. For more information read the Usage
document that comes with the LAME distribution.
- -b n: Set constant bitrate (bitrate: n
= 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 kbit/s). The higher the bitrate, the higher the
quality.
- -V m -b n: Enable variable bitrate encoding
(variable bitrate encoding quality: m = 0, 1, ..., 9)
and set the minimum allowed bitrate (bitrate: n = 8, 16,
24,... , 320 kbit/s). This minimum allowed bitrate is useful to prevent LAME VBR from using some very aggressive compression which can cause some distortion due to small flaws in the psycho-acoustic model.
The lower the variable bitrate encoding quality
number, the higher the quality of the encoded file. Thus a variable bitrate
encoding quality number closer to 0 will force LAME to encode at a higher
quality (use bitrates above the minimum allowed).
- -m n: Set stereo mode used by LAME (stereo mode: n
= m (mono), n = s
(stereo), n = j
(joint stereo) and n = f
(forced mid/side stereo)).
Mono is the default mode for mono input files. If -m m is specified for a stereo input file, the two channels will be averaged into a mono signal.
Joint stereo or jstereo is the default mode for stereo files with fixed bitrates of
160 kbit/s or less. At higher fixed bitrates, the default is stereo. For VBR encoding, jstereo is the default for VBR quality > 4, and stereo is the default for VBR quality <= 4. You can override all of these defaults by
specifying the mode on the command-line.
Jstereo means the encoder can use (on a frame by frame bases) either regular stereo (just encode left and right channels independently) or mid/side stereo. In mid/side stereo, the mid (L+R) and side (L-R) channels are encoded, and more bits are allocated to the mid channel than the side channel. This will effectively increase the bandwidth if the signal does not have too much stereo separation.
Mid/side stereo is basically a trick to increase bandwidth. At 128 kbit/s, it is clearly worth while. At higher bitrates it is less
useful.
Using mid/side stereo inappropriately can result in audible compression artifacts. To much switching between mid/side and regular stereo can also sound bad. To determine when to switch to mid/side stereo, LAME uses a much more sophisticated algorithm than that described in the ISO documentation.
Forced mid/side stereo forces all frames to be encoded mid/side stereo. It should only be used if you are sure every frame of the input file has very little stereo
separation.
- -h: Enables specialized mid/side masking thresholds to be used in jstereo mode. Will sound better in jstereo mode but is
about 20% slower. -h also enables a more accurate but slightly slower quantization formula. Since high quality is our goal, this parameter should
always be used.
High quality Constant Bitrate encoding settings
LAME 3.87
r3mix.net
recommends 256 kbit/s high quality stereo encoding. Translating this to LAME
parameters it gives -b 256 -m s -h. Thus enter this -b
256 -m s -h in the Additional command line options field.
See the screenshot on the left for an example. Also note that we don't use EAC's
Bit rate dropdown box to specify the bitrate. Putting -b
256 in the Additional command line options
will override the settings of this dropdown box.
LAME 3.88 and 3.89
For LAME 3.88 and 3.89 r3mix.net
recommends -b
256 -m s -h --lowpass 19.5.
LAME 3.90a (recommended)
For LAME 3.90a r3mix.net
recommends -b
256 -m s -q 0 --lowpass 19.5.
When uploading to newsgroups or FTPs 256 kbit/s MP3s are sometimes considered
as a little bit overkill. Most people do not hear the difference between 192
kbit/s encoded files and 256 kbit/s. Therefore you may choose to use -b
192 -m s -q 0 --lowpass 19.5 instead. 192 kbit/s is nowadays the preferred bitrate for
Internet distribution although Variable Bitrate is gaining popularity very fast
and will probably replace the aging 192 kbit/s standard. However, for personal use, or if you just care about
quality always go for 256 kbit/s.
|
High quality Variable Bitrate encoding settings
LAME 3.87
LAME is currently the only MP3 encoder optimally tweaked for Variable Bitrate
encoding unlike Fraunhofer and which does not mess up like Xing. For VBR
encoding r3mix.net
recommends somewhat more advanced settings: -V 1 -b 128 -m j -h
-q 1. Joint stereo is used. some people claim that joint stereo is not good.
But this only applies to the Fraunhofer and Xing encoder. LAME offers perfect
tweaked joint stereo encoding. The extra -q 1 switch is another quality/size switch.
It is said to replace the -h switch when using
VBR. This is what r3mix.net has to say about it:
-q 1 saves you a lot of bits without real quality concessions. I use it with
-V 1, and never had a bad experience with it. It makes the encoder rely more on the
psycho-acoustics model, yielding less bits for the same quality. There are reports of
-q 1 combined with variable bitrate quality parameter -V
higher than 4 giving poorer results, but since -V 1 is what I use, not much of a problem I think.
Why not using -V 0 for even higher quality? -V
1 -b 128 -m j gives a perfect balance between quality and space (about 160 to 190 kbit/s). If you use
-V 0 (or -m s) you end up with a file of about 220 kbit/s. Due to the imperfect nature of the psycho-acoustic model and quantization
algorithms of a perceptual encoder, you can better opt for the safe 256 kbit/s CBR solution if you don't mind ending up with such large files.
Using -V 0 does not sound better than a fixed 256 kbit/s
encoding as stated in the Lame manual.
Enter this -V 1 -b 128 -m j -h -q 1 in the Additional
command line options field. See the screenshot on the left for an example.
LAME 3.88 and 3.89
LAME 3.88 and 3.89 are for variable bitrate a lot slower than the previous versions
(using the new settings of course), but its quality is much better according to the experts.
For LAME 3.88 r3mix.net
recommends --r3mix -b 112. This equals to -V 1
-m j -h --athtype 3 --lowpass 19.5 -b 112.
LAME 3.90a (recommended)
LAME 3.90a has many quality and speed enhancements over the previous
versions. Therefore it's recommended to use this version, especially when
encoding Variable Bitrate MP3s. For LAME 3.90a r3mix.net
recommends --r3mix. This equals to --nspsytune --vbr-mtrh -V1 -mj -h -b96 --lowpass 19.5 --athtype 3 --ns-sfb21 2 -Z --scale 0.98.
For an explanation of all those switches see the Quality page at r3mix.net.
Variable Bitrate encoding is getting more and more popular for distributing
files over the Internet. With the correct settings (see above) its quality is
identical to high quality Constant Bitrate encoding (-b
256 -m s -q 0 --lowpass 19.5), but the file size is a lot smaller - modem
friendlier! The disadvantage of VBR is that certain older MP3 players or
hardware decoders are not able to play the files or give incorrect time
indication. Also encoding to VBR takes a lot longer than CBR... However, for
Internet distribution VBR is the way to go!
|
When you are sure the settings are correct for your needs click the OK button.
EAC is now configured to extract to high quality MP3 files. See Extracting Tracks To Your Harddisk
for more information about this.
|
|