>>101136604
Tell them that scripting langauges peaked at perl.
use strict;
use warnings FATAL => "all";
use v5.10;
my $video_file = qr{
\. (?: mp4 | mpe?g | mkv | webm? | avi | flv | wmv | m4v ) \z
}x;
my @files = map { chomp; s|\A\./||r } qx{ find -type f };
FILE:
for my $file (@files) {
if (!($file =~ $video_file)) {
next;
}
my @lines = split /\n/, get_output($file);
if (!@lines) {
next;
}
for my $line (@lines) {
if ($line =~ /(\d+(?:\.\d+)?)\s+fps\b/) {
printf "%-6s %s\n", $1, $file;
next FILE;
}
}
printf "%-6s %s\n", "undef", $file;
}
sub get_output {
my $file = shift;
pipe my($read, $write);
my $pid = fork;
if (!$pid) {
close $read;
close STDOUT;
close STDERR;
open STDOUT, ">&", $write;
open STDERR, ">&", $write;
exec "ffprobe", $file;
}
else {
close $write;
local $/;
my $output = <$read>;
waitpid $pid, 0;
if ($?) {
say STDERR "ERROR: ffprobe failed: $?";
return;
}
return $output;
}
}