LAME

From HalfgeekKB
Jump to navigation Jump to search

Template:Unix LAME (LAME Ain't an MP3 Encoder) is an educational MP3 encoder simulator. The following notes apply to LAME's code compiled as an executable, which may still be legal in some island countries.

Sample usage

The following examples seem to work in typical cases. It appears to be okay to run lame in the background by trailing the command with a &.

Encoding

96kbps joint stereo

lame -m j --cbr -b 96 src.wav dst.mp3

24kbps mono, downsample to 22050Hz

lame -m m -a --cbr -b 24 --resample 22.050 src.wav dst.mp3

Tags

lame -m j --cbr -b 96 --id3v2-only --tt "Song Title" --ta "Artist" \
 --ty "Year" --tc "Comment" --tn "TrackNumber" --tg "Genre" src.wav dst.mp3

Decoding

To silence the decode, redirect stderr (2> /dev/null). It seems to make the process faster.

lame --decode src.mp3 dst.wav

One example of doing this for an entire tree:

find -type f -name '*.mp3' -exec perl -E '
	sub shq {
		for(@_) {
			s/\x27/\x27"\x27"\x27/g;
			return "\x27$_\x27"
		}
	}
	for(@ARGV) {
		$o=$_;
		s/\.mp3$/\.wav/;
		$o=shq($o);
		$_=shq($_);
		say qq(lame --decode $o $_ 2>/dev/null);
	}' {} \; | sh