+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,
+ };
+}
+
+my %info = (
+ '.flac' => \&flacinfo,
+ '.mp3' => \&mp3info,
+ '.ogg' => \&vorbisinfo,
+ '.oga' => \&vorbisinfo,
+ '.mp4' => \&mp4info,
+ '.aac' => \&mp4info,
+ '.m4a' => \&mp4info,
+);
+