Common and recommended switches
Common settings
% lame [options] inputfile [outputfile]
Either name may be given as -, meaning standard input or standard output, so that LAME can sit in the middle of a pipeline.
lame --help lists the options in common use and lame --longhelp lists all of them; Detailed Settings describes each one.
-
Constant Bitrate: -b number or
--preset cbr number Valid values
for the -b settings depend on the sampling rate1.
lame -b 128 sample.wav sample.mp3
-
Variable Bitrate (ABR mode):
--abr number or --preset number
Valid values for the --abr setting range from 8 to 320.
lame --abr 128 sample.wav sample.mp3
-
Variable Bitrate (VBR mode):
-V number Valid values
are from 0 to 9, with decimal values possible, where 0 is the highest quality
while 9.999 is the lowest one.
lame -V2 sample.wav sample.mp3
Hydrogenaudio recommended settings
-
Very high quality, HiFi, home, or quiet listening, with best file size2 :
-V0 (avg. 245 kbps) or -V1
(avg. 225 kbps) or -V2 (avg. 190 kbps) or -V3 (avg. 175 kbps).
VBR settings will normally produce transparent results. Audible differences between these presets may exist, but are rare.
-
Very high quality, HiFi, home, or quiet listening, with maximum file size2 :
-b 320
This CBR mode will maximize the MP3's bitrate and overall file size. The extra space may allow for some parts of the audio to be compressed with fewer sacrifices, but to date, no one has produced ABX test results demonstrating that perceived quality is ever better than the highest VBR profiles described above.
-
Portable, listening in noisy conditions, lower bitrate, smaller file size:
-V4 (avg. 160 kbps) or -V5
(avg. 130 kbps) or -V6 (avg. 115 kbps)
-V6 produces an "acceptable" quality, while -V4 should be close to perceptual transparency.
-
Very low bitrate, small sizes, eg. for voice, radio, mono encoding :
--abr 80 (stereo) or --abr 56 -m m (mono)
For very low bitrates, up to 100kbps, ABR is most often the best solution. --preset voice is only available in the command line front-end, and is there for compatibility. It is currently mapped to --abr 56 -mm, so that means that the recommendation would be to encode in mono, and use ABR.
Examples
Constant bitrate
-
Fixed bitrate, joint stereo, 128 kbps:
lame -b 128 sample.wav sample.mp3
-
The same, at the highest quality setting, which is also the
slowest:
lame -q 0 -b 128 sample.wav sample.mp3
-
The same, encoding fast and at lower quality - no noise
shaping:
lame -f -b 128 sample.wav sample.mp3
Variable bitrate
LAME has two kinds of variable bitrate, ABR and VBR.
ABR is the kind usually found in other MP3 encoders, and in Vorbis and AAC. The number of bits is decided by some measure of the audio - the perceptual entropy, say, or simply how many bits a given set of coding tables needs - rather than by the encoding error actually made. It should always give results at least as good as constant bitrate at the same average.
-
ABR at an average of about 128 kbps:
lame --abr 128 sample.wav sample.mp3
-
Another way of asking for the same thing:
lame --preset 128 sample.wav sample.mp3
VBR decides the number of bits for each frame from the quantisation error it actually measures against the masking it estimates. 0 is the highest quality and makes the largest files, 9.999 the lowest and the smallest; decimals are allowed, such as 4.51. The sizes that result depend on the music: typically -V5 averages around 132 kbps and -V2 around 200 kbps.
-
VBR at quality 2:
lame -V2 sample.wav sample.mp3
Low bitrates
At around 24 kbps per channel and below, a 16 kHz sampling rate together with lowpass filtering gives better results than keeping the full bandwidth. LAME does this by itself, as commercial encoders do. Where the result is filtered more or less than suits the material, --resample, --lowpass and --lowpass-width set it by hand.
-
Mono voice at a low bitrate, resampled and filtered
explicitly:
lame --abr 56 -m m --resample 16 --lowpass 7 sample.wav sample.mp3
Streaming
With - on both sides LAME reads from standard input and writes to standard output, so it can be put in a pipeline:
cat inputfile | lame -b 128 - - > output.mp3
Raw PCM has no header to describe it, so its format has to be given on the command line - here mono at 22.05 kHz, encoded at 24 kbps:
cat inputfile | lame -r -s 22.05 -m m -b 24 - - > output.mp3
Scripts
The misc directory of the source distribution holds scripts for running LAME over many files at once.
| Script | What it is |
|---|---|
| mlame | bash; encodes a directory tree. mlame -? explains its options. |
| auenc | sh; run it with no arguments for instructions. |
| mugeco.sh | sh; encodes with the tags taken from the file names. |
| mk_mp3.sh | sh; encodes the WAV files in a directory. |
| lameid3.pl | perl; re-encodes MP3 files and carries their ID3 tags across. |
| lame4dos.bat | Windows batch file. |
| Lame.vbs | Windows Script Host; lameGUI.html is a front end for it. |
-
Codec sample frequencies (kHz) bitrates (kbps) MPEG-1 layer III 32, 44.1, 48 32 40 48 56 64 80 96 112 128 160 192 224 256 320 MPEG-2 layer III 16, 22.05, 24 8 16 24 32 40 48 56 64 80 96 112 128 144 160 MPEG-2.5 layer III 8, 11.025, 12 8 16 24 32 40 48 56 64 - Lossy codecs, like MP3, should not be used for archiving, since the nature of lossy encoding always changes the original sound, even if it sounds transparent. Use lossless codecs for this purpose.