473,385 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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
Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. my $perl = "G:\Perl\bin\perl.exe";
  6. use IPC::Open3;
  7.  
  8. my @list = glob('*.mp3 *.MP3 *.mp4 *.mpg');
  9. foreach my $song (@list){
  10. print "$song \n";
  11. my $filename = $song;
  12.  
  13. my %videoInfo = videoInfo($filename);
  14.  
  15. print "duration: " . $videoInfo{'duration'}. "\n";
  16. }
  17. sub videoInfo {
  18.  
  19.     # ffmpeg command
  20.  
  21.     my $ffmpeg = "usr\bin\ffmpeg";
  22.  
  23.  
  24.  
  25.   my %finfo = (
  26.  
  27.                  'duration'     => "00:00:00.00",
  28. );
  29.  
  30.  
  31.  
  32.     my $file = shift;
  33.  
  34.  
  35.  
  36.     # escaping characters
  37.  
  38.     $file =~ s/(\W)/\\$1/g;
  39.  
  40.  
  41.  
  42.     open3( "</dev/null", ">/dev/null", \*ERPH, "$ffmpeg -i $file" ) or
  43.      die "can't run $ffmpeg\n";
  44.  
  45.     my @res = <ERPH>;
  46.  
  47.  foreach (@res) {
  48.  
  49.  
  50.  
  51.         # duration
  52.  
  53.         if (m!Duration: ([0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9])!) {
  54.  
  55.             $finfo{'duration'} = $1;
  56.  
  57.         }
  58.  
  59.   }
  60.  
  61.  
  62.  
  63.     my $tenths  = substr( $finfo{'duration'}, 9, 2 );
  64.  
  65.     my $seconds = substr( $finfo{'duration'}, 6, 2 );
  66.  
  67.     my $minutes = substr( $finfo{'duration'}, 3, 2 );
  68.  
  69.     my $hours   = substr( $finfo{'duration'}, 0, 2 );
  70.  
  71.     $finfo{'durationsecs'} = ( $tenths * .01 ) + $seconds + ( $minutes * 60 ) + ( $hours * 360 );
  72.  
  73.  
  74.  
  75.     return %finfo;
  76.  
  77. }
Jan 19 '11 #1
1 3069
numberwhun
3,509 Expert Mod 2GB
So, on the command line type:

Expand|Select|Wrap|Line Numbers
  1. perl <filename>
  2.  
Jan 19 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ronald Evers | last post by:
Hey all, I want to store passwords in a postgresql database. Currently I use the MD5Password class below and I've been developing on windows. I ran into problems when running my application on...
2
by: Tim Williams | last post by:
I'm using Python 2.3.2 and tkFileDialog in a program I have. I'm trying to use this on Linux (RH 8.0) and Windows 2000. When I first upgraded from v2.2 to v2.3. I noticed that...
1
by: corrado | last post by:
Hello I have an application running several thread to display some financial data; basically I have a thread displaying HTML tables by means of Tkhtml, another implementing a scrolling ticker...
1
by: ÖÜÕÑÌÎ | last post by:
hi,I want to get the names of the files in a directory on the linux and windows platform. I found that _findfirst(),_findnext() can work under windows but the code cann't work under linux ,if...
2
by: Andrej Litowka | last post by:
Hi All! If anybody know, how I cann set an enviroment variable (with ANSI C) on Windows similar like on Linux. I tried setenv, but the function doesn't work correct on Windows - it sets env....
11
by: Muralish | last post by:
Anyone please expalin the difference between Linux and Windows why linux is used as Servers in many companies than windows why linux is less virus effected Concept behind opensource
2
by: Oliver Bleckmann | last post by:
Short question: I want my source to compile - without changes - on both linux and windows, so what libs can i use for 'independent' gui programming? does a gtk based progam compile on linux?...
3
by: Blubaugh, David A. | last post by:
To All, I was wondering if it was possible to utilize python to share a memory resource between a linux and windows system?? It should be stated that both the Linux (CENTOS 5) and windows...
0
by: Blubaugh, David A. | last post by:
Diez, What you have said is extremely concerning. I am now using VMware. With Linux as the Master and windows as the guest operating system. I was wondering if you have ever had to develop...
3
by: Lakshmyb | last post by:
Hi, Currently I am trying to port my application from Linux to windows. I need some inputs on the following: 1. how easily the sockets can be ported from Linux to Windows 2. whether I have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.