Created
January 13, 2009 20:36
-
-
Save kga/46608 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Perl6::Say; | |
use IPC::Cmd qw/can_run run/; | |
use YAML; | |
my $file = shift || 'sample.mp4'; | |
-e $file or die $!; | |
can_run('ffmpeg') or die 'FFmpeg is not installed'; | |
run( command => [qw/ffmpeg -i/, $file], buffer => \my $out ); | |
print $out; | |
my (%video, %audio); | |
($audio{format}, $audio{rate}, $audio{channel}) = $out =~ /.+Stream.+Audio: (\w+?), (\d+ Hz), (\w+?),/; | |
($video{format}, $video{what}, $video{x}, $video{y}, $video{frate}) = $out =~ /.+Stream.+Video: (\w+?), (\w+?), (?:(\d+)x(\d+)), (\d+(?:\.\d+))/; | |
print Dump \%video; | |
print Dump \%audio; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment