Change path to the ffmpeg for windows xp. I have attached the script here...
audinfo.txt
audinfo.txt
Code:
#!usr/bin/perl
use strict;
use warnings;
my $perl = "G:\Perl\bin\perl.exe";
use IPC::Open3;
my @list = glob('*.mp3 *.MP3 *.mp4 *.mpg');
foreach my $song (@list){
print "$song \n";
my $filename = $song;
my %videoInfo = videoInfo($filename);
print "duration: " . $videoInfo{'duration'}. "\n";
}
sub videoInfo {
# ffmpeg command
my $ffmpeg = "usr\bin\ffmpeg";
my %finfo = (
'duration' => "00:00:00.00",
);
my $file = shift;
# escaping characters
$file =~ s/(\W)/\\$1/g;
open3( "</dev/null", ">/dev/null", \*ERPH, "$ffmpeg -i $file" ) or
die "can't run $ffmpeg\n";
my @res = <ERPH>;
foreach (@res) {
# duration
if (m!Duration: ([0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9])!) {
$finfo{'duration'} = $1;
}
}
my $tenths = substr( $finfo{'duration'}, 9, 2 );
my $seconds = substr( $finfo{'duration'}, 6, 2 );
my $minutes = substr( $finfo{'duration'}, 3, 2 );
my $hours = substr( $finfo{'duration'}, 0, 2 );
$finfo{'durationsecs'} = ( $tenths * .01 ) + $seconds + ( $minutes * 60 ) + ( $hours * 360 );
return %finfo;
}
Comment