#!/usr/local/bin/perl use strict; use Audio::FLAC::Header; my $debug = 0; my @reslist; my %res; while (my $inputfile=) { chomp $inputfile; my $outputfile = $inputfile; $outputfile =~ s/\.flac$/.ogg/i; if (!-e $inputfile) { push(@reslist, $inputfile); $res{$inputfile} = 'NOTFOUND'; print STDERR "$inputfile does not exist, skipping.\n"; next; } if (-e $outputfile) { push(@reslist, $inputfile); $res{$inputfile} = 'SKIPPED:EXISTS'; print STDERR "$outputfile exists already, skipping.\n"; next; } print "\n** Converting ${inputfile} to ${outputfile} **\n"; my $flac = Audio::FLAC::Header->new($inputfile); my $flaccmd="/usr/local/bin/flac -s -d -c -- ".quotemeta(${inputfile}); my $cmd="/usr/local/bin/oggenc -Q -b 256 -m 64 -M 350 -o ".quotemeta(${outputfile}); my $tags = $flac->tags(); foreach (keys %$tags) { next if ($_ eq "VENDOR"); my $tag=quotemeta($tags->{$_}); print STDERR "$_: $tags->{$_}\n" if ($debug); $cmd .= " -c ${_}=$tag"; } $cmd .= " /dev/stdin"; print STDERR "Input command is : $flaccmd\n" if ($debug); print STDERR "Output command is: $cmd\n" if ($debug); system("$flaccmd | $cmd"); my $result=$?; if ($result == 0) { $result="OK"; } else { $result = "err #$result"; } push(@reslist, $inputfile); $res{$inputfile} = $result; print "Command returned $result.\n"; } print "\n\nREPORT:\n"; foreach my $t (@reslist) { if ($res{$t} ne "OK") { $res{$t} = "FAIL ($res{$t})"; } my $str = " ".$res{$t}; $str .= " " until(length($str) >= 25); print "$str $t\n"; } __END__