Skip to content

Instantly share code, notes, and snippets.

@kga
Created January 13, 2009 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kga/46608 to your computer and use it in GitHub Desktop.
Save kga/46608 to your computer and use it in GitHub Desktop.
#!/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