1# 2# From: Per Bolmstedt <tomten@kol14.com> 3# 4# AC> If someone has scripts that read input ID3 tags and convert 5# AC> them to args for lame (which then encodes the tags into the 6# AC> output files), let me know, too! 7# 8# This is easy peasy using Perl. Especially using Chris Nandor's excellent 9# MP3::Info package (available on CPAN). Here's a program I just wrote that 10# I think does what you want. Invoke it with "<program> <file> [options]" 11# (where the options can include an output filename), like for example: 12# 13# lameid3.pl HQ.mp3 LQ.mp3 -fv 14# 15# (Note how the syntax differs from that of Lame's.) The program will 16# extract ID3 tags from the input file and invoke Lame with arguments for 17# including them. (This program has not undergone any real testing..) 18 19use MP3::Info; 20use strict; 21 22my %flds = ( 23 TITLE => 'tt', 24 ARTIST => 'ta', 25 ALBUM => 'tl', 26 YEAR => 'ty', 27 COMMENT => 'tc', 28 GENRE => 'tg', 29 TRACKNUM => 'tn' 30 ); 31 32my $f = shift @ARGV; 33my $s = "lame ${f} " . &makeid3args( $f ) . join ' ', @ARGV; 34print STDERR "[${s}]\n"; 35system( $s ); 36 37sub makeid3args( $ ) 38{ 39 my $s; 40 if ( my $tag = get_mp3tag( @_->[ 0 ] ) ) 41 { 42 for ( keys %flds ) 43 { 44 if ( $tag->{ $_ } ) 45 { 46 $s .= sprintf( 47 "--%s \"%s\" ", 48 %flds->{ $_ }, 49 $tag->{ $_ } ); 50 } 51 } 52 } 53 return $s || ""; 54} 55 56