How to run a ffmpeg perl script on Windows?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ajit Teli
    New Member
    • Jan 2011
    • 4

    #1

    How to run a ffmpeg perl script on Windows?

    Change path to the ffmpeg for windows xp. I have attached the script here...

    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;
    
    }
    Last edited by Niheel; Jan 19 '11, 01:27 PM.
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    So, on the command line type:

    Code:
    perl <filename>

    Comment

    Working...