|
Packit |
47f805 |
#
|
|
Packit |
47f805 |
# From: Per Bolmstedt <tomten@kol14.com>
|
|
Packit |
47f805 |
#
|
|
Packit |
47f805 |
# AC> If someone has scripts that read input ID3 tags and convert
|
|
Packit |
47f805 |
# AC> them to args for lame (which then encodes the tags into the
|
|
Packit |
47f805 |
# AC> output files), let me know, too!
|
|
Packit |
47f805 |
#
|
|
Packit |
47f805 |
# This is easy peasy using Perl. Especially using Chris Nandor's excellent
|
|
Packit |
47f805 |
# MP3::Info package (available on CPAN). Here's a program I just wrote that
|
|
Packit |
47f805 |
# I think does what you want. Invoke it with "<program> <file> [options]"
|
|
Packit |
47f805 |
# (where the options can include an output filename), like for example:
|
|
Packit |
47f805 |
#
|
|
Packit |
47f805 |
# lameid3.pl HQ.mp3 LQ.mp3 -fv
|
|
Packit |
47f805 |
#
|
|
Packit |
47f805 |
# (Note how the syntax differs from that of Lame's.) The program will
|
|
Packit |
47f805 |
# extract ID3 tags from the input file and invoke Lame with arguments for
|
|
Packit |
47f805 |
# including them. (This program has not undergone any real testing..)
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
use MP3::Info;
|
|
Packit |
47f805 |
use strict;
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
my %flds = (
|
|
Packit |
47f805 |
TITLE => 'tt',
|
|
Packit |
47f805 |
ARTIST => 'ta',
|
|
Packit |
47f805 |
ALBUM => 'tl',
|
|
Packit |
47f805 |
YEAR => 'ty',
|
|
Packit |
47f805 |
COMMENT => 'tc',
|
|
Packit |
47f805 |
GENRE => 'tg',
|
|
Packit |
47f805 |
TRACKNUM => 'tn'
|
|
Packit |
47f805 |
);
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
my $f = shift @ARGV;
|
|
Packit |
47f805 |
my $s = "lame ${f} " . &makeid3args( $f ) . join ' ', @ARGV;
|
|
Packit |
47f805 |
print STDERR "[${s}]\n";
|
|
Packit |
47f805 |
system( $s );
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
sub makeid3args( $ )
|
|
Packit |
47f805 |
{
|
|
Packit |
47f805 |
my $s;
|
|
Packit |
47f805 |
if ( my $tag = get_mp3tag( @_->[ 0 ] ) )
|
|
Packit |
47f805 |
{
|
|
Packit |
47f805 |
for ( keys %flds )
|
|
Packit |
47f805 |
{
|
|
Packit |
47f805 |
if ( $tag->{ $_ } )
|
|
Packit |
47f805 |
{
|
|
Packit |
47f805 |
$s .= sprintf(
|
|
Packit |
47f805 |
"--%s \"%s\" ",
|
|
Packit |
47f805 |
%flds->{ $_ },
|
|
Packit |
47f805 |
$tag->{ $_ } );
|
|
Packit |
47f805 |
}
|
|
Packit |
47f805 |
}
|
|
Packit |
47f805 |
}
|
|
Packit |
47f805 |
return $s || "";
|
|
Packit |
47f805 |
}
|
|
Packit |
47f805 |
|