LinuxCommandLibrary

lame

Encode audio files into MP3 format

TLDR

Encode an audio file to MP3 using CBR 320 kbit/second

$ lame -b 320 [path/to/file].wav [path/to/output].mp3
copy

Encode an audio file to MP3 using the V0 preset
$ lame -V 0 [path/to/file].wav [path/to/output].mp3
copy

Encode an audio file to AAC
$ lame [path/to/file].wav [path/to/output].aac
copy

SYNOPSIS

lame [options] [infile] [outfile]

PARAMETERS

-h, --help
    Show summary of options

-V n
    VBR quality (0=highest, 9=lowest); default -V 4

-b n
    CBR or ABR bitrate in kbps (8-320)

--abr n
    Average bitrate ABR mode

--preset medium|standard|extreme|insane
    Recommended presets for quality/size

-q n
    Quality 0(highest)-9(lowest); for fine-tuning

--joint-stereo
    Enable joint stereo (default for <192kbps)

--noasm
    Disable assembly optimizations

--nogap
    Disable gapless encoding

--replaygain-fast
    Compute ReplayGain tags

-S, --silent
    Suppress progress messages

-t, --nogap
    No gap between frames

--decode
    Decode MP3 to WAV (infile required)

DESCRIPTION

LAME is a widely used, free command-line tool for encoding audio files into MP3 format. It supports input from WAV, AIFF, and other formats, producing high-quality MP3s with advanced psychoacoustic algorithms to minimize perceptual distortion. Key features include constant bitrate (CBR), variable bitrate (VBR), and average bitrate (ABR) modes, joint stereo encoding, and gapless playback support.

LAME excels in transparency at lower bitrates (e.g., 128kbps VBR often matches 192kbps CBR). It's the de facto standard for MP3 encoding, powering tools like Audacity and FFmpeg. Usage is straightforward: pipe audio or specify files, with options for bitrate, quality presets, and tags.

Developed as an open-source alternative to proprietary encoders, LAME implements the MP3 standard (ISO/IEC 11172-3 and 13818-3) with optimizations for speed and quality. It's licensed under LGPL, allowing static linking. Install via package managers like apt install lame on Debian-based systems.

CAVEATS

Lossy compression discards data; test quality subjectively. Not for lossless needs. Requires compilation flags for full optimizations. Output defaults to .mp3 extension.

PRESETS GUIDE

Use --preset medium (~170kbps VBR transparent), standard (~170-210kbps), extreme (~220kbps+). Ideal for most users without manual tuning.

Example: lame --preset standard input.wav

BATCH ENCODING

For directories: for f in *.wav; do lame -V2 "$f" "${f%.wav}.mp3"; done
Supports stdin/stdout: cat audio.raw | lame -r -x -

HISTORY

Project started in 1998 by Mike Cheng as a frontend to 'lame' encoder; core by Takehiro Tomisawa. Achieved transparency milestone in 2002. Maintained by LAME team; latest stable 3.100 (2017). Integral to open-source audio ecosystem.

SEE ALSO

ffmpeg(1), sox(1), mpg123(1), normalize-audio(1)

Copied to clipboard