use constant MEDIAINFO_BIN => "/usr/bin/mediainfo";
use constant MEDIAINFO_ARGS => "--Inform=General;%Duration% \nVideo;%Duration% %Width% %Height% \nAudio;%Duration% %Format% %BitRate% %Language%";
use constant DISCR_THRESH => 15;
sub chk_mp4_duration($$) {
my ($path, $thresh) = (shift, shift);
open(MEDIAINFO, "-|", MEDIAINFO_BIN, MEDIAINFO_ARGS, $path) or die;
chomp(my $line = <MEDIAINFO>);
close(MEDIAINFO);
if($line !~ m/^(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s([^\s]+)\s(\d+)\s(\w+)$/) {
print "! Can't get duriations for $path ($line)\n";
return -1;
}
my ($c, $v, $w, $h, $a, $f, $r, $l) = ($1, $2, $3, $4, $5, $6, $7, $8);
my $discrepancy = abs($v - $a) / 1000;
print "! $path |v @ " . $w . "x" . $h . "|=" . fmt_millis($v)
. " |a ". $f . " @". $r . " (" . $l . ")|=" . fmt_millis($a)
. " ($discrepancy s)\n" if $discrepancy > $thresh;
return $c;
}
...
chk_mp4_duration($src, DISCR_THRESH);
...