diff options
author | wiso <wiso@svn> | 2010-05-07 17:57:13 +0000 |
---|---|---|
committer | wiso <wiso@svn> | 2010-05-07 17:57:13 +0000 |
commit | eaf1ff993ef2b2b573cd537fca24990af834bd36 (patch) | |
tree | 3573164af4938f6191aa8049f7762b480776c29e /lib/liblame/misc/lameid3.pl | |
parent | c6e8ce5f942d477dd44cf52fc43d42db632be05f (diff) |
copy lame-3.98.4 to trunk
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@29897 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'lib/liblame/misc/lameid3.pl')
-rw-r--r-- | lib/liblame/misc/lameid3.pl | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/liblame/misc/lameid3.pl b/lib/liblame/misc/lameid3.pl new file mode 100644 index 0000000000..53528779fd --- /dev/null +++ b/lib/liblame/misc/lameid3.pl @@ -0,0 +1,55 @@ +# +# From: Per Bolmstedt <tomten@kol14.com> +# +# AC> If someone has scripts that read input ID3 tags and convert +# AC> them to args for lame (which then encodes the tags into the +# AC> output files), let me know, too! +# +# This is easy peasy using Perl. Especially using Chris Nandor's excellent +# MP3::Info package (available on CPAN). Here's a program I just wrote that +# I think does what you want. Invoke it with "<program> <file> [options]" +# (where the options can include an output filename), like for example: +# +# lameid3.pl HQ.mp3 LQ.mp3 -fv +# +# (Note how the syntax differs from that of Lame's.) The program will +# extract ID3 tags from the input file and invoke Lame with arguments for +# including them. (This program has not undergone any real testing..) + +use MP3::Info; +use strict; + +my %flds = ( + TITLE => 'tt', + ARTIST => 'ta', + ALBUM => 'tl', + YEAR => 'ty', + COMMENT => 'tc', + GENRE => 'tg', + TRACKNUM => 'tn' + ); + +my $f = shift @ARGV; +my $s = "lame ${f} " . &makeid3args( $f ) . join ' ', @ARGV; +print STDERR "[${s}]\n"; +system( $s ); + +sub makeid3args( $ ) +{ + my $s; + if ( my $tag = get_mp3tag( @_->[ 0 ] ) ) + { + for ( keys %flds ) + { + if ( $tag->{ $_ } ) + { + $s .= sprintf( + "--%s \"%s\" ", + %flds->{ $_ }, + $tag->{ $_ } ); + } + } + } + return $s || ""; +} + |