MP3: LAME DLL
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 DLL encoder.
For people reading the whole tutorial at once several parts on this page will
be familiar already. It's just copy/pasted from the external LAME encoder part
of the tutorial. I didn't feel liking writing a whole new story about it. I
could of course leave it away and put links to the external LAME encoder part of
the tutorial to clarify things, but some people are too lazy to check those out
and then bug me with stupid e-mails complaining about missing information.
Author: Mark Taylor, Mike Cheng, Takehiro Tominiga, Robert Hegemann and other
Platform: Windows 95/98/ME/NT/2000
Price: Open Source Freeware
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
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
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. Anyway, for most people those predefined settings satisfy so I'll
explain the usage of the DLL here. If you want a more configurable LAME encoder
use the external executable version of LAME. The
advantage of the DLL is real-time encoding. The external encoder has to wait for
a track to be extracted completely to WAV first before the encoding can begin.
DLL based encoders or codecs can encode in real time without extracting to a
temporary WAV first.
Since LAME 3.88 r3mix.net
recommends a LAME command-line using advanced parameters which EAC cannot pass
to the LAME DLL. Therefore you better
use the external executable version of LAME.
Obtain the LAME DLL 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
At the moment of writing LAME 3.89 is the latest version. Download LAME
3.89. Check Dmitry
Kutsanov's website regularly for new updates of the encoder! After downloading the zip
file, decompress lame_enc.dll to your harddisk using WinZip
or similar. It's recommended to put lame.exe in the c:\windows\system
folder on a Windows 95/98/ME system, and c:\winnt\system32 on
Windows NT/2000 systems. Why? Then the LAME DLL can be shared between other
programs supporting the DLL. If you do not ant to put LAME in the mentioned
directories you must place it in the same directory as the Exact Audio Copy
executable eac.exe. Otherwise EAC will not be able to detect lame_enc.dll.
Configuring EAC for the LAME DLL 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.
Make sure Use external program for compression is disabled
on the External Compression tab. Otherwise you are not able
to select the LAME DLL encoder. Then on the Waveform tab
select LAME MPEG Layer-3 Encoder v3.87 DLL v1.16 from the Wave
format drop down box. Depending on your version of the DLL the version and
build information may differ. Also note that a new tab has appeared in the Compression options
window: the LAME DLL tab. If you cannot see this new tab and
cannot select the LAME DLL from the dropdown box, lame_enc.dll
is probably not at the correct location.
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
Check Do not write WAV header to file to avoid the writing
of a WAV header. MP3 cannot be wrapped by a WAV header. Therefore this option
must be enabled.
Enter .mp3 in the File extension for
headerless files. Note the dot (point) before the extension. It is necessary
to put the dot in front of the letters mp3.
On the LAME DLL tab make sure Insert CRC Checksum
is disabled. While LAME is one of the
few encoders which actually supports 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!
The Write Xing VBR header on VBR encoding should be
enabled. For most people knowing something about MP3 quality the name Xing gives
them pimples and is associated with low quality MP3s. But if Xing invents a good
thing it may be said. The Xing header helps MP3 players to identify a file as a
Variable Bitrate file. It will of course only be written to Variable Bitrate
Setting the LAME encoding options
can be configured in EAC by selecting the bitrate from the Sample
format drop down box on the Waveform tab. Unlike with the
highly configurable external executable version of LAME, there is no possibility
of overriding these settings with custom parameters. As mentioned before we will
use the r3mix.net
recommended settings for MP3 encoding. r3mix.net
has done extensive tests with the LAME encoder and defined the optimal settings
for the best quality.
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 but the DLL implementation in Exact Audio Copy
does not allow to use those. The parameters passed to LAME are also shown below,
but you cannot see those. It's all wrapped in a nice user interface.
- Sample format: In this drop down box you can specify
the bitrate. -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
Below the CBR bitrates in the drop down box you can find the VBR settings.
If you want to use Variable Bitrate encoding you must select one of the
bitrates with VBR in the name. When using VBR, the
selected bitrate is the minimum allowed bitrate. This 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.
- Output mode: In this drop down box you can select the
stereo mode used by LAME. -m n: Set stereo mode (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
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
- Quality: In this drop down box the encoding quality
can be set. Since the best quality is what we need only set this to High
Quality. -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.
- Maximum VBR bitrate: Here you can specify the maximum
bitrate used by Variable Bitrate encoding. -B n: Set
maximum allowed 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
bitrates can be used and thus the higher the quality. By default LAME uses
the maximum of 320 kbit/s as highest allowed bitrate. For high quality
encoding it is not recommended to lower this value!
- Use VBR quality: 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). -V m
(variable bitrate encoding quality: m = 0, 1, ..., 9)
and set the minimum allowed bitrate (bitrate: n = 8, 16,
24,... , 320 kbit/s).
High quality Constant Bitrate encoding settings
recommends 256 kbit/s high quality stereo encoding.
See the screenshots on the left for an example.
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 -h instead. 192 kbit/s is nowadays the preferred bitrate for
Internet distribution. However, for personal use, or if you just care about
quality always go for 256 kbit/s.
High quality Variable Bitrate encoding settings
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
recommends somewhat more advanced settings: -V 1 -b 128 -m j -h
-q 1. Now here's the problem with the DLL. The -q 1
switch cannot be used when using the DLL. That is the reason why I do not
recommend the usage of the LAME DLL for Variable Bitrate encoding. You better
use the external executable version of LAME. 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.
The closest to r3mix.net's
settings you can get is -V 1 -b 128 -m j -h. 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. 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.
See the screenshot on the left for an example of using the -V 1 -b 128 -m j -h
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.