- title => fix($ogg->comment('TITLE') || '?'),
- artist => fix ($ogg->comment('artist') || '?'),
- year => fix ($ogg->comment('DATE') || '?'),
- album => fix ($ogg->comment('ALBUM') || '?'),
- tracknumber => fix ($ogg->comment('TRACKNUMBER') || '?'),
- tracktotal => fix ($ogg->comment('TRACKTOTAL') || '?'),
- genre => fix ($ogg->comment('GENRE')) || '?',
- file => $file,
+ title => scalar $ogg->comment('TITLE'),
+ artist => scalar $ogg->comment('artist'),
+ year => scalar $ogg->comment('DATE'),
+ album => scalar $ogg->comment('ALBUM'),
+ tracknumber => scalar $ogg->comment('TRACKNUMBER'),
+ tracktotal => scalar $ogg->comment('TRACKTOTAL'),
+ genre => scalar $ogg->comment('GENRE'),
+ file => scalar fileparse $file,
+ }
+}
+
+sub mp4_format ($){ ## no critic (ProhibitSubroutinePrototypes)
+ my $encoding = $_[0];
+ return 'AAC' if $encoding eq 'mp4a';
+ return 'ALAC' if $encoding eq 'alac';
+ "MP4-$encoding"
+}
+
+sub mp4info{
+ my $file=$_[0];
+ my %tag = map { ref() ? $_ : encode 'UTF-8', $_ } %{get_mp4tag $file};
+ my %info = %{get_mp4info $file};
+
+ freeze +{
+ format => mp4_format $info{ENCODING},
+ title => $tag{TITLE},
+ artist => $tag{ARTIST},
+ year => $tag{YEAR},
+ album => $tag{ALBUM},
+ tracknumber => $tag{TRACKNUM},
+ tracktotal => ($tag{TRKN} ? $tag{TRKN}->[1] : undef),
+ genre => $tag{GENRE},
+ file => scalar fileparse $file,
+ };
+}
+
+sub opusinfo {
+ my $file = $_[0];
+ my %info;
+ my @info = `opusinfo \Q$file`;
+ return unless @info;
+ for (@info) {
+ chomp;
+ $info{$1} = $2 if /\s*([A-Z]+)=(.*)$/;