mplayer comes with an midentify utility that does mostly what you want.
The output looks like variable assignments, so it is pretty easy to use in scripts/simple to parse.
If midentify isn't installed with your mplayer package, you might have an midentify.sh script in /usr/share/mplayer or something like that. If not, midenfify just runs mplayer with a specific set of arguments:
#!/bin/sh
#
# This is a wrapper around the -identify functionality.
# It is supposed to escape the output properly, so it can be easily
# used in shellscripts by 'eval'ing the output of this script.
#
# Written by Tobias Diedrich <ranma+mplayer@tdiedrich.de>
# Licensed under GNU GPL.
if [ -z "$1" ]; then
echo "Usage: midentify.sh <file> [<file> ...]"
exit 1
fi
mplayer -vo null -ao null -frames 0 -identify "$@" 2>/dev/null |
sed -ne '/^ID_/ {
s/[]()|&;<>`'"'"'\\!$" []/\\&/g;p
}'
The -ao, -vo and -frames parameters prevent mplayer from actually playing the clip. The rest is just formatting.
Example:
$ midentify some_random.avi
ID_VIDEO_ID=0
ID_AUDIO_ID=0
...
ID_VIDEO_BITRATE=258488
ID_VIDEO_WIDTH=320
ID_VIDEO_HEIGHT=240
ID_VIDEO_FPS=29.917
...
ID_LENGTH=4216.76
...
ID_AUDIO_BITRATE=64000
ID_AUDIO_RATE=22050
...