Hi
I have a perl script that prints all the video and audio file information(playing duration).
It works fine in one of my friends linux laptop.
But it doesn't work in my both windows and linux.
My friend told me I have to do install some module ( ppm instal ...... )
but I have no idea what module to install in windows.
in the code I have used
use IPC::Open3;
Also I have used some file handlers.
Please suggest me which module to install . I tried ppm install IPC::Open3 in command prompt, but it did not work.
It gave me this error "No missing packages to install"
Help me please to execute this code.
---------- Post updated at 12:23 PM ---------- Previous update was at 10:58 AM ----------
Ok , I understand this is not the module problem. Because I feel that the module is already installed .
Here is the code that works fine in linux, but I am not able to make it work in windows.
#!c:\perl\bin\perl.exe
use strict;
use warnings;
#require "./xxx.pl";
use IPC::Open3;
my @list = glob('*.mp3 *.mp4 *.mpg *.aac *.midi *m3u *.mpa *.dat *.avi');
open(FILEHANDLE, ">vinform.txt") or die "cannot open file";
print FILEHANDLE "NAME \t\t\t DURATION \t DURATION IN SECONDS \n\n";
close(FILEHANDLE);
foreach my $song (@list){
print "$song \n";
my $filename = $song;
my %videoInfo = videoInfo($filename);
print "duration: " . $videoInfo{'duration'}. "\n";
print "durationsecs: " . $videoInfo{'durationsecs'}. "\n\n";
open(FILEHANDLE, ">>vinform.txt") or die "cannot open file";
print FILEHANDLE "$song \t\t";
print FILEHANDLE "". $videoInfo{'duration'}. "\t\t";
print FILEHANDLE "". $videoInfo{'durationsecs'}. "\n \n";
}
close(FILEHANDLE);
sub videoInfo {
# ffmpeg command
my $ffmpeg = 'C:\ffmpeg.exe';
my %finfo = (
'duration' => "00:00:00.00",
'durationsecs' => "0"
);
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;
}
Its just displaying 00:00:00:00 as the output.
Please help me with this assignment.
---------- Post updated at 05:09 PM ---------- Previous update was at 12:23 PM ----------
ok, you need to install ffmpeg.exe and give path in the code.
But I am trying to extract the output from ffmpeg and display it,
I also have to insert the values to my sql database once I get this time and file name.