Date: Wed, 15 Nov 2000 19:48:57 +1300 (NZDT) From: =?iso-8859-1?q?Graham=20Guttocks?= <graham_guttocks@yahoo.co.nz> To: freebsd-multimedia@FreeBSD.ORG Subject: Re: preserving id3 tag with mp3-->wav-->mp3 conversions Message-ID: <20001115064857.42190.qmail@web10306.mail.yahoo.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] Ben Smithurst <ben@FreeBSD.org> wrote: > Alternatively write a small perl script to do it, there's nothing > particularly magic about MP3 tags. Thanks for the info, I didn't realise the nature of mp3 tags were so simple. In any case, I've attached the perl script I hacked up this afternoon in case it may be of use to anyone else. I plan to let it run on my 12GB of MP3s while I'm out of town this weekend. Cheers, Graham _____________________________________________________________________________ http://clubs.yahoo.com.au - Yahoo! Clubs - Join a club or build your own! [-- Attachment #2 --] #!/usr/bin/perl # Starts in the current working directory and recursively decodes all # MP3s into WAVE format and then encodes them back into MP3, # preserving their id3 tags in the process. Useful for redoing poorly # encoded MP3s downloaded off the net. use MP3::Info; # <http://search.cpan.org/search?module=MP3::Info> use File::Recurse; # <http://search.cpan.org/search?module=File::Recurse> my %files = Recurse(['.'], {match => '\.mp3$'}); foreach (sort keys %files) { $dir = $_; foreach (@{ $files{$_} }) { $mp3 = "$dir/$_"; $newmp3 = "$mp3.OLD"; # uses lame (beta) <http://lame.sourceforge.net> $decode = "lame --decode --mp3input $newmp3 $newmp3.wav 2>/dev/null"; $encode = "lame -p -h -b 160 $newmp3.wav $mp3 2>/dev/null"; $tag = get_mp3tag($mp3); # fetch the original mp3 file's id3 tag. rename($mp3,$newmp3); # rename the file. print "re-encoding $mp3\n"; system("$decode"); # decode it into wave. system("$encode"); # encode the wav into a new mp3. set_mp3tag("$mp3", $tag); # set the new mp3's id3 tag. unlink("$newmp3.wav","$newmp3"); # cleanup by deleting the old mp3 and wave. } } print "\n"; print "Done\n";
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001115064857.42190.qmail>
