in reply to Get size and bitrate of video with perl and ffmpeg
Also, running subprocesseses using list context is safer in case of some special characters in the file name: open(FILE,"-|",qw(ffprobe -i),$file).
Unfortunately, it will be necessary to use some special tricks to hide the STDERR, for example, (untested; written for ugly avconv output)
Unfortunately, it will be necessary to use some special tricks to hide the STDERR, for example, (untested; written for ugly avconv output)
use IPC::Run 'run'; my $file = $ARGV[0] || die; my $line; run [ qw(ffprobe -show_streams),$file ], '&>', \$line || die "$!\n"; my ($width,$height); for (split /\n/,$line) { $width = $1 if /width=(\d+)/; $height = $1 if /height=(\d+)/; # ... $_ eq '[/STREAM]' && defined $width && defined $height && print "$ +{width}x${height}\n" && last }
Sorry if my advice was wrong.
|
---|
In Section
Cool Uses for Perl