[Gllug] Command line tool to find video dimensions?
salsaman at xs4all.nl
salsaman at xs4all.nl
Thu May 31 17:06:35 UTC 2007
On Thu, May 31, 2007 14:03, sas.18752793 at bloglines.com wrote:
> --- Greater London Linux User Group <gllug at gllug.org.uk wrote:
>> Exists an
> open source command-line tool that I can call to figure out the
>> dimensions
> of a video?
>
> If you've got mplayer (http://www.mplayerhq.hu/) installed,
> you can use something like
>
> mplayer video.avi -identify -frames 0 | grep
> ID_
>
> to get details about the video.
>
> --
> Gllug mailing list - Gllug at gllug.org.uk
> http://lists.gllug.org.uk/mailman/listinfo/gllug
>
>
In perl:
#!/usr/bin/perl
$file=$ARGV[0];
# $file might be a stream, so we need to cache a bit
system("mplayer -identify -vo null -ao null -frames 0 -cache 32
\"$file\">tmpfile 2>/dev/null </dev/null");
$hsize=`grep ID_VIDEO_WIDTH tmpfile 2>/dev/null`;
$hsize=(split("=",(split("\n",$hsize))[0]))[1];
chomp($hsize);
$vsize=`grep ID_VIDEO_HEIGHT tmpfile 2>/dev/null`;
$vsize=(split("=",(split("\n",$vsize))[0]))[1];
chomp($vsize);
unlink "tmpfile";
print "Video size is $hsize x $vsize\n";
If you want to get other details, look at:
http://lives.cvs.sourceforge.net/lives/lives/smogrify?view=markup
and search for "sub get_file_info"
Gabriel.
http://lives.sourceforge.net
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list