Difference between revisions of "LAME"

From HalfgeekKB
Jump to navigation Jump to search
 
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{unix}}[[Category:Sound]]
 
'''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.
 
'''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.
  
Line 5: Line 6:
 
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 &.
 
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 &.
  
==96kbps joint stereo==
+
==Encoding==
 +
 
 +
===96kbps joint stereo===
  
 
  lame -m j --cbr -b 96 src.wav dst.mp3
 
  lame -m j --cbr -b 96 src.wav dst.mp3
  
==24kbps mono, downsample to 22050Hz==
+
===24kbps mono, downsample to 22050Hz===
  
 
  lame -m m -a --cbr -b 24 --resample 22.050 src.wav dst.mp3
 
  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 (<code>2&gt; /dev/null</code>).  It seems to make the process faster.
 +
 +
lame --decode src.mp3 dst.wav
 +
 +
One example of doing this for an entire tree:
 +
 +
<syntaxhighlight lang=bash>
 +
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
 +
</syntaxhighlight>

Latest revision as of 08:58, 7 March 2015

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