lame(1) | LAME audio compressor | lame(1) |
lame - create mp3 audio files
lame [options] <infile> <outfile>
LAME is a program which can be used to create compressed audio files. (Lame ain't an MP3 encoder). These audio files can be played back by popular MP3 players such as mpg123 or madplay. To read from stdin, use "-" for <infile>. To write to stdout, use "-" for <outfile>.
Input options:
Required only for raw PCM input files. Otherwise it will be determined from the header of the input file.
LAME will automatically resample the input file to one of the supported MP3 samplerates if necessary.
Required only for raw PCM input files. Otherwise it will be determined from the header of the input file.
Required only for raw PCM input files.
Required only for raw PCM input files and only available at bitwidth 8.
Required only for raw PCM input files.
Required only for raw PCM input files.
Operational options:
Joint-stereo is the default mode for stereo files.
(s)imple stereo (Forced LR)
In this mode, the encoder makes no use of potentially existing
correlations between the two input channels. It can, however, negotiate
the bit demand between both channel, i.e. give one channel more bits if
the other contains silence or needs less bits because of a lower
complexity.
(j)oint stereo
In this mode, the encoder can use (on a frame by frame basis) either L/R
stereo 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. When there isn't too much stereo
separation, this effectively increases the bandwidth, so having higher
quality with the same amount of bits.
Using mid/side stereo inappropriately can result in audible compression artifacts. Too 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 the one described in the ISO documentation.
(f)orced MS stereo
Forces all frames to be encoded with mid/side stereo. It should be used
only if you are sure that every frame of the input file has very little
stereo separation.
(d)ual channel
In this mode, the 2 channels will be totally independently encoded. Each
channel will have exactly half of the bitrate. This mode is designed for
applications like dual languages encoding (for example: English in one
channel and French in the other). Using this encoding mode for regular
stereo files will result in a lower quality encoding.
(m)ono
The input will be encoded as a mono signal. If it was a stereo signal, it
will be downsampled to mono. The downmix is calculated as the sum of the
left and right channel, attenuated by 6 dB. Also note that, if using a
stereo RAW PCM stream, you need to use the -a parameter.
(l)eft channel only
The input will be encoded as a mono signal. If it was a stereo signal, the
left channel will be encoded only.
(r)ight channel only
The input will be encoded as a mono signal. If it was a stereo signal, the
right channel will be encoded only.
This option is only needed in the case of raw PCM stereo input (because LAME cannot determine the number of channels in the input file). To encode a stereo RAW PCM input file as mono, use lame -a -m m
For WAV and AIFF input files, using -m m will always produce a mono .mp3 file from both mono and stereo input.
However, even if an mp3 decoder is required to support free bitrates at least up to 320 kbps, many players are unable to deal with it.
Tests have shown that the following decoders support free
format:
in_mpg123 up to 560 kbps
l3dec up to 310 kbps
LAME up to 640 kbps
MAD up to 640 kbps
If -t is used (disable wav header), LAME will output raw pcm in native endian format. You can use -x to swap bytes order.
This option is not usable if the MP3 decoder was explicitly disabled in the build of LAME.
When --decode is specified (decode to WAV), this flag will disable writing of the WAV header. The output will be raw pcm, native endian format. Use -x to swap bytes.
n > 1: increase volume
n = 1: no effect
n < 1: reduce volume
Use with care, since most MP3 decoders will truncate data which decodes to values greater than 32768.
This computes "Radio" ReplayGain on the input data stream after user‐specified volume‐scaling and/or resampling.
The ReplayGain analysis does not affect the content of a compressed data stream itself, it is a value stored in the header of a sound file. Information on the purpose of ReplayGain and the algorithms used is available from http://www.replaygain.org/.
Only the "RadioGain" Replaygain value is computed, it is stored in the LAME tag. The analysis is performed with the reference volume equal to 89dB. Note: the reference volume has been changed from 83dB on transition from version 3.95 to 3.95.1.
This switch is enabled by default.
See also: --replaygain-accurate, --noreplaygain
This computes "Radio" ReplayGain on the decoded data stream, finds the peak sample by decoding on the fly the encoded data stream and stores it in the file.
The ReplayGain analysis does not affect the content of a compressed data stream itself, it is a value stored in the header of a sound file. Information on the purpose of ReplayGain and the algorithms used is available from http://www.replaygain.org/.
By default, LAME performs ReplayGain analysis on the input data (after the user‐specified volume scaling). This behavior might give slightly inaccurate results because the data on the output of a lossy compression/decompression sequence differs from the initial input data. When --replaygain-accurate is specified the mp3 stream gets decoded on the fly and the analysis is performed on the decoded data stream. Although theoretically this method gives more accurate results, it has several disadvantages:
The apparent advantage is that:
Only the "RadioGain" ReplayGain value is computed, it is stored in the LAME tag. The analysis is performed with the reference volume equal to 89dB. Note: the reference volume has been changed from 83dB on transition from version 3.95 to 3.95.1.
This option is not usable if the MP3 decoder was explicitly disabled in the build of LAME. (Note: if LAME is compiled without the MP3 decoder, ReplayGain analysis is performed on the input data after user-specified volume scaling).
See also: --replaygain-fast, --noreplaygain --clipdetect
By default ReplayGain analysis is enabled. This switch disables it.
See also: --replaygain-fast, --replaygain-accurate
Enable --replaygain-accurate and print a message whether clipping occurs and how far in dB the waveform is from full scale.
This option is not usable if the MP3 decoder was explicitly disabled in the build of LAME.
See also: --replaygain-accurate
Have a look at the PRESETS section below.
--preset help gives more infos about the the used options in these presets.
Verbosity:
Noise shaping & psycho acoustic algorithms:
Bitrate is of course the main influence on quality. The higher the bitrate, the higher the quality. But for a given bitrate, we have a choice of algorithms to determine the best scalefactors and Huffman encoding (noise shaping).
For CBR and ABR, the following table applies:
-q 0:
Use the best algorithms (Best Huffman coding search, full outer loop, and
the highest precision of several parameters).
-q 1 to q 4:
Similar to -q 0 without the full outer loop and decreasing precision of
parameters the further from q0. -q 3 is the default.
-q 5 and -q 6:
Same as -q 7, but enables noise shaping and increases subblock gain
-q 7 to -q 9:
Same as -f. Very fast, OK quality. Psychoacoustics are used for pre-echo
and mid/side stereo, but no noise-shaping is done.
For the default VBR mode since LAME 3.98, the following table applies :
-q 0 to -q 4:
include all features of the other modes and additionally use the best
search when applying Huffman coding.
-q 5 and -q 6:
include all features of -q7, calculate and consider actual quantisation
noise, and additionally enable subblock gain.
-q 7 to -q 9
This level uses a psymodel but does not calculate quantisation noise when
encoding: it takes a quick guess.
CBR (constant bitrate, the default) options:
For MPEG-2 (sampling frequencies of 16, 22.05 and 24 kHz)
n = 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160
For MPEG-2.5 (sampling frequencies of 8, 11.025 and 12 kHz)
n = 8, 16, 24, 32, 40, 48, 56, 64
Default is 128 for MPEG1 and 64 for MPEG2 and 32 for MPEG2.5
(64, 32 and 16 respectively in case of mono).
ABR (average bitrate) options:
It can be combined with the -b and -B switches like: lame --abr 123 -b 64 -B 192 a.wav a.mp3 which would limit the allowed frame sizes between 64 and 192 kbits.
The use of -B is NOT RECOMMENDED. A 128 kbps CBR bitstream, because of the bit reservoir, can actually have frames which use as many bits as a 320 kbps frame. VBR modes minimize the use of the bit reservoir, and thus need to allow 320 kbps frames to get the same flexibility as CBR streams.
VBR (variable bitrate) options:
ABR and VBR options:
For MPEG-2 (sampling frequencies of 16, 22.05 and 24 kHz)
n = 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160
For MPEG-2.5 (sampling frequencies of 8, 11.025 and 12 kHz)
n = 8, 16, 24, 32, 40, 48, 56, 64
Specifies the minimum bitrate to be used. However, in order to avoid wasted space, the smallest frame size available will be used during silences.
For MPEG-2 (sampling frequencies of 16, 22.05 and 24 kHz)
n = 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160
For MPEG-2.5 (sampling frequencies of 8, 11.025 and 12 kHz)
n = 8, 16, 24, 32, 40, 48, 56, 64
Specifies the maximum allowed bitrate.
Note: If you own an mp3 hardware player build upon a MAS 3503 chip, you must set maximum bitrate to no more than 224 kpbs.
Without this option, the minimum bitrate will be ignored for passages of analog silence, i.e. when the music level is below the absolute threshold of human hearing (ATH).
Experimental options:
When LAME searches for a "good" quantization, it has to compare the actual one with the best one found so far. The comparison says which one is better, the best so far or the actual. The -X parameter selects between different approaches to make this decision, -X0 being the default mode:
-X0
The criteria are (in order of importance):
* less distorted scalefactor bands
* the sum of noise over the thresholds is lower
* the total noise is lower
-X1
The actual is better if the maximum noise over all scalefactor bands is
less than the best so far.
-X2
The actual is better if the total sum of noise is lower than the best so
far.
-X3
The actual is better if the total sum of noise is lower than the best so
far and the maximum noise over all scalefactor bands is less than the
best so far plus 2dB.
-X4
Not yet documented.
-X5
The criteria are (in order of importance):
* the sum of noise over the thresholds is lower
* the total sum of noise is lower
-X6
The criteria are (in order of importance):
* the sum of noise over the thresholds is lower
* the maximum noise over all scalefactor bands is lower
* the total sum of noise is lower
-X7
The criteria are:
* less distorted scalefactor bands
or
* the sum of noise over the thresholds is lower
MP3 header/stream options:
n = (none, default)
5 = 0/15 microseconds
c = citt j.17
All this does is set a flag in the bitstream. If you have a PCM input file where one of the above types of (obsolete) emphasis has been applied, you can set this flag in LAME. Then the mp3 decoder should de-emphasize the output during playback, although most decoders ignore this flag.
A better solution would be to apply the de-emphasis with a standalone utility before encoding, and then encode without -e.
Filter options:
ID3 tag options:
Analysis options:
LAME is able to embed ID3 v1, v1.1 or v2 tags inside the encoded MP3 file. This allows one to have some useful information about the music track included inside the file. Those data can be read by most MP3 players.
Lame will smartly choose which tags to use. It will add ID3 v2 tags only if the input comments won't fit in v1 or v1.1 tags, i.e. if they are more than 30 characters. In this case, both v1 and v2 tags will be added, to ensure reading of tags by MP3 players which are unable to read ID3 v2 tags.
LAME is able to encode your music using one of its 3 encoding modes: constant bitrate (CBR), average bitrate (ABR) and variable bitrate (VBR).
The --preset switches are aliases over LAME settings.
To activate these presets:
For VBR modes (generally highest quality):
For CBR 320kbps (highest quality possible from the --preset switches):
For ABR modes (high quality per given bitrate but not as high as VBR):
Fixed bit rate jstereo 128kbs encoding:
Fixed bit rate jstereo 128 kbps encoding, highest quality:
To disable joint stereo encoding (slightly faster, but less quality at bitrates <= 128 kbps):
Variable bitrate (use -V n to adjust quality/filesize):
Streaming mono 22.05 kHz raw pcm, 24 kbps output:
Streaming mono 44.1 kHz raw pcm, with downsampling to 22.05 kHz:
Encode with the standard preset:
Probably there are some.
LAME originally developed by Mike Cheng and now maintained by Mark Taylor, and the LAME team. GPSYCHO psycho-acoustic model by Mark Taylor. (See http://www.mp3dev.org/). mpglib by Michael Hipp Manual page by William Schelter, Nils Faerber, Alexander Leidinger, and Rogério Brito.
December 8, 2013 | LAME 3.99 |