Video::FFmpeg - Retrieve video properties using libavformat such as: height width codec fps
use Video::FFmpeg; use Switch; my $info = Video::FFmpeg::AVFormat->new($ARGV[0]); print "Duration: ",$info->duration,"\n"; my @video = $info->video; print "num video streams: ",$#video+1,"\n"; my @audio = $info->audio; print "num audio streams: ",$#audio+1,"\n"; my @sub = $info->subtitle; print "num sub streams: ",$#sub+1,"\n"; my @streams = $info->streams; for my $id (0 .. $#streams){ my $stream = $streams[$id]; print $stream->codec_type,"stream $id\n"; print "\ttype: ",$stream->codec_type,"\n"; print "\tcodec: ",$stream->codec,"\n"; print "\tlanguage: ",$stream->lang,"\n"; switch($stream->codec_type){ case "video" { print "\tfps: ",$stream->fps,"\n"; print "\tDAR: ",$stream->display_aspect,"\n"; } case "audio" { print "\tsample rate: ",$stream->sample_rate,"hz\n"; print "\taudio language: ",$stream->lang,"\n"; } case "subtitle" { print "\tsub codec: ",$stream->codec,"\n"; print "\tsub language: ",$stream->lang,"\n"; } } };
AVFormat Constructor
returns the filename of the $info object
duration of the stream, in HH:MM:SS.MS.
position of the first frame of the component, in microseconds
total stream bitrate in bit/s, 0 if not available.
if called in scalar context, returns the first Video::FFmpeg::AVStream::Video object. if called in list context, it returns all Video::FFmpeg::AVStream::Video objects
if called in scalar context, returns the first Video::FFmpeg::AVStream::Audio object. if called in list context, it returns all Video::FFmpeg::AVStream::Audio objects
if called in scalar context, returns the first Video::FFmpeg::AVStream::Subtitle object. if called in list context, it returns all Video::FFmpeg::AVStream::Subtitle objects
returns a list of all Video::FFmpeg::AVStream objects.
name of the codec
returns one of "audio", "video", "subtitle", "data", "attachment", "data", or "unknown"
returns the stream's language
the average bitrate in bit/s
samples per second (hz)
number of audio channels
picture width
picture height
frames per second, 0 if not available.
aspect ratio of the picture in "W:H" format
aspect ratio of the pixels in "W:H" format, or undef if not defined;
Video::FFmpeg is a factory class for working with video files. Video::FFmpeg utilises FFmpeg's libavformat, and provides a basic interface.
None by default.
Max Vohra, <max@seattlenetworks.com> html://www.seattlenetworks.com/
Copyright (C) 2009 by Max Vohra
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.
To install Video::FFmpeg, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Video::FFmpeg
CPAN shell
perl -MCPAN -e shell install Video::FFmpeg
For more information on module installation, please visit the detailed CPAN module installation guide.