[Gllug] Command line tool to find video dimensions?
Tethys
sta296 at astradyne.co.uk
Fri Jun 1 01:12:47 UTC 2007
Nix writes:
>Perl does support pipes you know, and grep, and stuff, natively; no need
>for temporary files
In fact, no need for perl...
#!/bin/bash
if [ $# -eq 0 ]; then
echo usage: $(basename "$0") "filename [...]"
exit 1
fi
for file in "$@"
do
output=$(mplayer -identify -vo null -ao null -frames 0 "$file" 2>&1)
width=
height=
[[ "$output" =~ "ID_VIDEO_WIDTH=([0-9]+)" ]] && width=${BASH_REMATCH[1]}
[[ "$output" =~ "ID_VIDEO_HEIGHT=([0-9]+)" ]] && height=${BASH_REMATCH[1]}
if [ -z "$width" -o -z "$height" ]; then
echo "$file: unknown size"
else
echo "$file: ${width}x$height"
fi
done
Tet
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list