lame(1) | LAME audio compressor | lame(1) |
NAME¶
lame - create mp3 audio filesSYNOPSIS¶
lame [options] <infile> <outfile>DESCRIPTION¶
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>.OPTIONS¶
Input options:- -r
- Assume the input file is raw pcm. Sampling rate and mono/stereo/jstereo
must be specified on the command line. For each stereo sample, LAME
expects the input data to be ordered left channel first, then right
channel. By default, LAME expects them to be signed integers with a
bitwidth of 16. Without -r, LAME will perform several
fseek()'s on the input file looking for WAV and AIFF headers.
- -x
- Swap bytes in the input file or output file when using --decode.
- -s sfreq
- sfreq = 8/11.025/12/16/22.05/24/32/44.1/48 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.
- --bitwidth n
- Input bit width per sample.
- --signed
- Instructs LAME that the samples from the input are signed (the default for 16, 24 and 32 bits raw pcm data). Required only for raw PCM input files.
- --unsigned
- Instructs LAME that the samples from the input are unsigned (the default for 8 bits raw pcm data, where 0x80 is zero). Required only for raw PCM input files and only available at bitwidth 8.
- --little-endian
- Instructs LAME that the samples from the input are in little-endian form. Required only for raw PCM input files.
- --big-endian
- Instructs LAME that the samples from the input are in big-endian form. Required only for raw PCM input files.
- --mp2input
- Assume the input file is a MPEG Layer II (ie MP2) file.
- --mp3input
- Assume the input file is a MP3 file.
- --nogap file1 file2 ...
- gapless encoding for a set of contiguous files
- --nogapout dir
- output dir for gapless encoding (must precede --nogap)
- -m mode
- mode = s, j, f, d, m, l, r
Joint-stereo is the default mode for stereo files with VBR when -V is
more than 4 or fixed bitrates of 160kbs or less. At higher fixed bitrates
or higher VBR settings, the default is stereo.
(s)imple stereo
- -a
- Mix the stereo input file to mono and encode as mono.
- -d
- Allows the left and right channels to use different block size types.
- --freeformat
- Produces a free format bitstream. With this option, you can use -b
with any bitrate higher than 8 kbps.
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:
- --decode
- Uses LAME for decoding to a wav file. The input file can be any input type supported by encoding, including layer II files. LAME uses a bugfixed version of mpglib for decoding. 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.
- -t
- Disable writing of the INFO Tag on encoding.
- --comp arg
- Instead of choosing bitrate, using this option, user can choose compression ratio to achieve.
- --scale n
- --scale-l n
- --scale-r n
- Scales input (every channel, only left channel or only right channel) by
n. This just multiplies the PCM data (after it has been converted
to floating point) by n.
n > 1: increase volume
- --replaygain-fast
- Compute ReplayGain fast but slightly inaccurately. 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
- --replaygain-accurate
- Compute ReplayGain more accurately and find the peak sample. This enables decoding on the fly, computes "Radio" ReplayGain on the decoded data stream, finds the peak sample of the decoded 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:
- *
- tests have shown that the difference between the ReplayGain values computed on the input data and decoded data is usually not greater than 0.5dB, although the minimum volume difference the human ear can perceive is about 1.0dB
- *
- decoding on the fly significantly slows down the encoding process
The apparent advantage is that:
- *
- with --replaygain-accurate the real peak sample is determined and stored in the file. The knowledge of the peak sample can be useful to decoders (players) to prevent a negative effect called 'clipping' that introduces distortion into the sound.
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
- --noreplaygain
- Disable ReplayGain analysis. By default ReplayGain analysis is enabled. This switch disables it. See also: --replaygain-fast, --replaygain-accurate
- --clipdetect
- Clipping detection. 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
- --preset type | [cbr] kbps
- Use one of the built-in presets. Have a look at the PRESETS section below. --preset help gives more infos about the the used options in these presets.
- --preset type | [cbr] kbps
- Use one of the built-in presets.
- --noasm type
- Disable specific assembly optimizations ( mmx / 3dnow / sse ). Quality will not increase, only speed will be reduced. If you have problems running Lame on a Cyrix/Via processor, disabling mmx optimizations might solve your problem.
- --disptime n
- Set the delay in seconds between two display updates.
- --nohist
- By default, LAME will display a bitrate histogram while producing VBR mp3
files. This will disable that feature.
- -S
- --silent
- --quiet
- Do not print anything on the screen.
- --verbose
- Print a lot of information on the screen.
- --help
- Display a list of available options.
- -q qual
- 0 <= qual <= 9
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).
-q 0:
- -h
- Use some quality improvements. Encoding will be slower, but the result
will be of higher quality. The behavior is the same as the -q 2
switch.
- -f
- This switch forces the encoder to use a faster encoding mode, but with a lower quality. The behavior is the same as the -q 7 switch. Noise shaping will be disabled, but psycho acoustics will still be computed for bit allocation and pre-echo detection.
- -b n
- For MPEG-1 (sampling frequencies of 32, 44.1 and 48 kHz)
- --cbr
- enforce use of constant bitrate
- --abr n
- Turns on encoding with a targeted average bitrate of n kbits, allowing to use frames of different sizes. The allowed range of n is 8 - 310, you can use any integer value within that range. 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.
- -v
- use variable bitrate (--vbr-new)
- --vbr-old
- Invokes the oldest, most tested VBR algorithm. It produces very good quality files, though is not very fast. This has, up through v3.89, been considered the "workhorse" VBR algorithm.
- --vbr-new
- Invokes the newest VBR algorithm. During the development of version 3.90, considerable tuning was done on this algorithm, and it is now considered to be on par with the original --vbr-old. It has the added advantage of being very fast (over twice as fast as --vbr-old).
- -V n
- 0 <= n <= 9
- -b bitrate
- For MPEG-1 (sampling frequencies of 32, 44.1 and 48 kHz)
- -B bitrate
- For MPEG-1 (sampling frequencies of 32, 44.1 and 48 kHz)
- -F
- Strictly enforce the -b option.
- -X n
- 0 <= n <= 7
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
- -Y
- lets LAME ignore noise in sfb21, like in CBR
- -e emp
- emp = n, 5, c
n = (none, default)
- -c
- Mark the encoded file as being copyrighted.
- -o
- Mark the encoded file as being a copy.
- -p
- Turn on CRC error protection.
- --nores
- Disable the bit reservoir. Each frame will then become independent from previous ones, but the quality will be lower.
- --strictly-enforce-ISO
- With this option, LAME will enforce the 7680 bit limitation on total frame
size.
- --lowpass freq
- Set a lowpass filtering frequency in kHz. Frequencies above the specified one will be cutoff.
- --lowpass-width freq
- Set the width of the lowpass filter. The default value is 15% of the lowpass frequency.
- --highpass freq
- Set an highpass filtering frequency in kHz. Frequencies below the specified one will be cutoff.
- --highpass-width freq
- Set the width of the highpass filter in kHz. The default value is 15% of the highpass frequency.
- --resample sfreq
- sfreq = 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, 48
- --tt title
- audio/song title (max 30 chars for version 1 tag)
- --ta artist
- audio/song artist (max 30 chars for version 1 tag)
- --tl album
- audio/song album (max 30 chars for version 1 tag)
- --ty year
- audio/song year of issue (1 to 9999)
- --tc comment
- user-defined text (max 30 chars for v1 tag, 28 for v1.1)
- --tn track[/total]
- audio/song track number and (optionally) the total number of tracks on the original recording. (track and total each 1 to 255. Providing just the track number creates v1.1 tag, providing a total forces v2.0).
- --tg genre
- audio/song genre (name or number in list)
- --add-id3v2
- force addition of version 2 tag
- --id3v1-only
- add only a version 1 tag
- --id3v2-only
- add only a version 2 tag
- --id3v2-latin1
- add following options in ISO-8859-1 text encoding.
- --id3v2-utf16
- add following options in unicode text encoding.
- --space-id3v1
- pad version 1 tag with spaces instead of nulls
- --pad-id3v2
- same as --pad-id3v2-size 128
- --pad-id3v2-size num
- adds version 2 tag, pad with extra "num" bytes
- --genre-list
- print alphabetically sorted ID3 genre list and exit
- --ignore-tag-errors
- ignore errors in values passed for tags, use defaults in case an error occurs
- -g
- run graphical analysis on <infile>. <infile> can also be a .mp3 file. (This feature is a compile time option. Your binary may for speed reasons be compiled without this.)
ID3 TAGS¶
LAME is able to embed ID3 v1, v1.1 or v2 tags inside the encoded MP3 file. This allows 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.ENCODING MODES¶
LAME is able to encode your music using one of its 3 encoding modes: constant bitrate (CBR), average bitrate (ABR) and variable bitrate (VBR).- Constant Bitrate (CBR)
- This is the default encoding mode, and also the most basic. In this mode, the bitrate will be the same for the whole file. It means that each part of your mp3 file will be using the same number of bits. The musical passage being a difficult one to encode or an easy one, the encoder will use the same bitrate, so the quality of your mp3 is variable. Complex parts will be of a lower quality than the easiest ones. The main advantage is that the final files size won't change and can be accurately predicted.
- Average Bitrate (ABR)
- In this mode, you choose the encoder will maintain an average bitrate while using higher bitrates for the parts of your music that need more bits. The result will be of higher quality than CBR encoding but the average file size will remain predictable, so this mode is highly recommended over CBR. This encoding mode is similar to what is referred as vbr in AAC or Liquid Audio (2 other compression technologies).
- Variable bitrate (VBR)
- In this mode, you choose the desired quality on a scale from 9 (lowest quality/biggest distortion) to 0 (highest quality/lowest distortion). Then encoder tries to maintain the given quality in the whole file by choosing the optimal number of bits to spend for each part of your music. The main advantage is that you are able to specify the quality level that you want to reach, but the inconvenient is that the final file size is totally unpredictable.
PRESETS¶
The --preset switches are aliases over LAME settings. To activate these presets: For VBR modes (generally highest quality):- --preset medium
- This preset should provide near transparency to most people on most music.
- --preset standard
- This preset should generally be transparent to most people on most music and is already quite high in quality.
- --preset extreme
- If you have extremely good hearing and similar equipment, this preset will generally provide slightly higher quality than the standard mode.
- --preset insane
- This preset will usually be overkill for most people and most situations, but if you must have the absolute highest quality with no regard to filesize, this is the way to go.
- --preset kbps
- Using this preset will usually give you good quality at a specified bitrate. Depending on the bitrate entered, this preset will determine the optimal settings for that particular situation. While this approach works, it is not nearly as flexible as VBR, and usually will not attain the same level of quality as VBR at higher bitrates.
- cbr
- If you use the ABR mode (read above) with a significant bitrate such as 80, 96, 112, 128, 160, 192, 224, 256, 320, you can use the cbr option to force CBR mode encoding instead of the standard ABR mode. ABR does provide higher quality but CBR may be useful in situations such as when streaming an MP3 over the Internet may be important.
EXAMPLES¶
Fixed bit rate jstereo 128kbs encoding:- lame sample.wav sample.mp3
- lame -h sample.wav sample.mp3
- lame -b 112 sample.wav sample.mp3
- lame -m s sample.wav sample.mp3
- lame -f sample.wav sample.mp3
- lame -h -V 6 sample.wav sample.mp3
- cat inputfile | lame -r -m m -b 24 -s 22.05 - - > output
- cat inputfile | lame -r -m m -b 24 --resample 22.05 - - > output
- lame --preset standard sample.wav sample.mp3
BUGS¶
Probably there are some.SEE ALSO¶
mpg123(1), madplay(1), sox(1)AUTHORS¶
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.
July 8, 2008 | LAME 3.99 |