LAME (Lame Ain't an MP3 Encoder) is a high-quality open-source MP3 encoder that offers extensive command-line functionality. This guide covers all available commands and options to help you get the most out of this powerful audio encoding tool.

Basic Usage

lame [options] input.wav output.mp3

You can also encode from standard input or output to standard output:

lame -r -s 44.1 -h - -

Quality and Bitrate Options

Bitrate Control

  • -b [bitrate] - Set constant bitrate (CBR) in kbps (default: 128)
  • --abr [bitrate] - Use average bitrate (ABR) encoding at specified kbps
  • -V [0-9] - Set variable bitrate (VBR) quality level (0=best, 9=worst)
  • --vbr-old - Use old variable bitrate algorithm (default in older versions)
  • --vbr-new - Use new variable bitrate algorithm (default in newer versions)
  • --vbr-mtrh - Use VBR method using RH psychoacoustics
  • -q [0-9] - Set quality of algorithm (0=best/slowest, 9=worst/fastest)
  • -h - Enable high quality mode
  • -f - Fast mode (slightly lower quality)

VBR Settings

  • --vbr-quality [0-9] - Set VBR quality (0=best, 9=worst)
  • -v - Enable VBR (Variable Bit Rate)
  • --preset [setting] - Use preset settings (standard, extreme, insane, etc.)
  • --alt-preset [setting] - Use alternative preset settings
  • --comp [0-999] - Set compression ratio
  • --cvbr - Strictly enforce minimum bitrate with ABR/VBR

Audio Processing Options

Resampling

  • --resample [frequency] - Resample to frequency (8, 11.025, 12, 16, 22.05, 24, 32, 44.1, 48 kHz)
  • -s [frequency] - Set sample frequency in kHz

Filtering

  • --lowpass [freq] - Set lowpass filter frequency in kHz
  • --lowpass-width [freq] - Set width of transition band in kHz
  • --highpass [freq] - Set highpass filter frequency in kHz
  • --highpass-width [freq] - Set width of transition band in kHz
  • --athonly - Only use the ATH for masking
  • --athlower [dB] - Lower the ATH by specified decibels
  • --athtype [type] - Set the type of ATH (0-4)

Channel Processing

  • -m m - Force mono output
  • -m s - Force stereo output
  • -m j - Force joint stereo
  • -m f - Force dual-channel stereo
  • -a - Downmix from stereo to mono
  • --scale [factor] - Scale input by factor
  • --scale-l [factor] - Scale left channel by factor
  • --scale-r [factor] - Scale right channel by factor
  • --replaygain-fast - Compute ReplayGain fast but slightly inaccurately
  • --replaygain-accurate - Compute ReplayGain accurately
  • --noreplaygain - Disable ReplayGain analysis
  • --clipdetect - Enable clipping detection
  • --noclipdetect - Disable clipping detection

ID3 Tag Options

  • --tt [title] - Set audio/song title
  • --ta [artist] - Set audio/song artist
  • --tl [album] - Set album name
  • --ty [year] - Set year
  • --tc [comment] - Set comment
  • --tn [track] - Set track number
  • --tg [genre] - Set genre
  • --add-id3v2 - Force addition of ID3 version 2 tag
  • --id3v1-only - Add only an ID3 version 1 tag
  • --id3v2-only - Add only an ID3 version 2 tag
  • --id3v2-latin1 - Use ISO-8859-1 encoding in ID3v2 tags
  • --id3v2-utf16 - Use UTF-16 encoding in ID3v2 tags
  • --id3v2-utf8 - Use UTF-8 encoding in ID3v2 tags
  • --space-id3v1 - Pad ID3v1 tag with spaces instead of nulls
  • --pad-id3v2 - Pad ID3v2 tag with extra 128 bytes
  • --pad-id3v2-size [size] - Pad ID3v2 tag with extra size bytes
  • --genre-list - Print list of available genres

File Input/Output Options

  • -r - Assume raw PCM input
  • -x - Swap bytes of input file
  • -a - Downmix from stereo to mono file
  • --brief - Print less verbose messages
  • --silent - Don't print status messages
  • -t - Disable VBR info tag
  • --big-endian - Input file is big-endian
  • --little-endian - Input file is little-endian
  • --signed - Input is signed data
  • --unsigned - Input is unsigned data
  • --bitwidth [bits] - Specify bit width of input (default 16)
  • --mp1input - Input file is MP1 file
  • --mp2input - Input file is MP2 file
  • --mp3input - Input file is MP3 file

Advanced Options

  • --nores - Disable bit reservoir
  • --strictly-enforce-ISO - Strictly enforce ISO compliance
  • --buffer-constraint [constraint] - Buffer constraints (0-7)
  • --athaa-type [type] - ATH auto adjust types (0-3)
  • -X [n] - Set max bitrate for VBR ABR
  • -Y - Force byte swapping
  • -Z - Force downmixing from stereo to mono
  • --noasm [cpu-features] - Disable assembly optimizations
  • --freeformat - Create a free format bitstream
  • --decode - Input is an MP3 file, decode to WAV

Miscellaneous Options

  • -S - Print Lame configuration and exit
  • --license - Print license information
  • -?, --help - Display help information
  • --longhelp - Display all help information
  • --config - Display encoder configuration
  • -v - Show version information
  • --nohist - Disable histogram display
  • --quiet - Don't show progress
  • --silent - Don't show any output on screen
  • --verbose - Show more information during encoding

Examples

Basic Encoding

lame input.wav output.mp3

High-Quality VBR Encoding

lame -V 0 input.wav output.mp3

Constant Bitrate 320kbps Encoding

lame -b 320 input.wav output.mp3

Average Bitrate (ABR) Encoding

lame --abr 192 input.wav output.mp3

Encoder Preset

lame --preset standard input.wav output.mp3

Joint Stereo with ID3 Tags

lame -m j --tt "Song Title" --ta "Artist" --tl "Album" input.wav output.mp3

Streaming Input to Output

cat input.wav | lame - output.mp3

Batch Encoding with Wildcards

for file in *.wav; do lame --preset standard "$file" "${file%.wav}.mp3"; done