#!/usr/bin/perl use Audio::FLAC::Header; my @t = qw(year 31557600 month 2627994 week 604800 day 86400 hour 3600 minute 60); my $flac; for (@ARGV) { if ($flac = Audio::FLAC::Header->new($_)) { flac_inf($flac,$_); flac_tags($flac); } else { warn "Can't open $_"; next; } } sub flac_inf { my $info = (shift)->info(); my $file = shift; my $osize = $$info{NUMCHANNELS} * $$info{TOTALSAMPLES} * ( $$info{BITSPERSAMPLE} / 8 ); my $csize = -s $file; my $t = $$info{TOTALSAMPLES} / $$info{SAMPLERATE}; for (keys %$info) { print "INF| $_: $info->{$_}\n"; } print "INF| originalsize: $osize\n"; print "INF| flacsize: $csize\n"; printf("INF| ratio: %1.5f\n", $csize / $osize); print "INF| time: " . int($t+.5) ."s\n"; print "INF| sanetime: " . sane_time($t) . "\n"; } sub flac_tags { my $tags = (shift)->tags(); for (keys %$tags) { print "TAG| $_: $tags->{$_}\n"; } } sub sane_time { my $t = shift; my ($u, $v, $o, $c); my @x=@t; # nasty while ($u = shift @x) { $v = shift @x; $c = int($t/$v); if ($c) { $t-=$c*$v; $o.=plural($c, $u); } } $o.=plural(int($t),'second'); return $o; } sub plural { return "@_[0] @_[1]" . (@_[0] != 1 ? 's ' : ' '); }