Mastering LAME encoder and sample usage

4/21/2011

I mostly try to keep as close as possible to the actual source and usage of software tools. One example is the wonderful and often used MP3 encoder LAME.

I filtered the output of the command lame --longhelp by deleting all the options that didn't seem useful for me. That's what came out:

LAME 32bits version 3.98.4 (http://www.mp3dev.org/)

usage: ./frontend/lame [options] <infile> [outfile]

RECOMMENDED:
    lame -V2 input.wav output.mp3

OPTIONS:
  Operational options:
    -a              downmix from stereo to mono file for mono encoding
    -m <mode>       (j)oint, (s)imple, (f)orce, (d)dual-mono, (m)ono
                    default is (j) or (s) depending on bitrate
                    joint  = joins the best possible of MS and LR stereo
                    simple = force LR stereo on all frames
                    force  = force MS stereo on all frames.
    --decode        input=mp3 file, output=wav

  Verbosity:
    --quiet         don't print anything on screen
    --brief         print more useful information
    --verbose       print a lot of useful information

  Noise shaping & psycho acoustic algorithms:
    -q <arg>        <arg> = 0...9.  Default  -q 5
                    -q 0:  Highest quality, very slow
                    -q 9:  Poor quality, but fast
    -h              Same as -q 2.   Recommended.
    -f              Same as -q 7.   Fast, ok quality

  CBR (constant bitrate, the default) options:
    -b <bitrate>    set the bitrate in kbps, default 128 kbps
    --cbr           enforce use of constant bitrate

  ABR options:
    --abr <bitrate> specify average bitrate desired (instead of quality)

  VBR options:
    -V n            quality setting for VBR.  default n=4
                    0=high quality,bigger files. 9=smaller files
    -v              the same as -V 4
    -b <bitrate>    specify minimum allowed bitrate, default  32 kbps
    -B <bitrate>    specify maximum allowed bitrate, default 320 kbps
    -t              disable writing LAME Tag

  Filter options:
  --lowpass <freq>        frequency(kHz), lowpass filter cutoff above freq
  --lowpass-width <freq>  frequency(kHz) - default 15% of lowpass freq
  --highpass <freq>       frequency(kHz), highpass filter cutoff below freq
  --highpass-width <freq> frequency(kHz) - default 15% of highpass freq
  --resample <sfreq>  sampling frequency of output file(kHz)- default=automatic

  ID3 tag options:
    --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. just the track number
                           creates v1.1 tag, providing a total forces v2.0).
    --tg <genre>    audio/song genre (name or number in list)
    --ti <file>     audio/song albumArt (jpeg/png/gif file, 128KB max, v2.3)
    --tv <id=value> user-defined frame specified by id and value (v2.3 tag)
    --add-id3v2     force addition of version 2 tag
    --id3v1-only    add only a version 1 tag
    --id3v2-only    add only a version 2 tag
    --genre-list    print alphabetically sorted ID3 genre list and exit
    --ignore-tag-errors  ignore errors in values passed for tags

    Note: A version 2 tag will NOT be added unless one of the input fields
    won't fit in a version 1 tag (e.g. the title string is longer than 30
    characters), or the '--add-id3v2' or '--id3v2-only' options are used,
    or output is redirected to stdout.

MPEG-1   layer III sample frequencies (kHz):  32  48  44.1
bitrates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320

MPEG-2   layer III sample frequencies (kHz):  16  24  22.05
bitrates (kbps):  8 16 24 32 40 48 56 64 80 96 112 128 144 160

MPEG-2.5 layer III sample frequencies (kHz):   8  12  11.025
bitrates (kbps):  8 16 24 32 40 48 56 64

 

Sample usage:

The project recommends using the -V 2 option in order to encode with a variable bitrate and a relatively good quality.

One typical usage would be the following. Here, the recommended variable bitrate quality setting is used and some of the most useful ID3-Tags are set.

lame -V 2 --tt testtitle --ta testartist --tl testalbum --ty 2011 --tc SimCoded Testsound.wav Testsound.mp3

When no option is given LAME seems to use a constant bitrate setting with 128kbps and a quality setting of 3.

If no ID3-Tags are desired, the simplest and most efficient usage would be:

lame -V 2 Testsound.wav Testsound.mp3


Leave Comment