How can I get the resolution (width and height) for a video file from a linux command line?

Viewed 113231

I've been digging through the mplayer/mencoder and ffmpeg documentation and I can't seem to come up with anything. I'm not especially picky as to the output format as I can use a regular expression to pull it out, I just can't seem to get the data in the first place.

10 Answers

MediaInfo has a command line version and provides the dimensions together with tons of other information.

Try midentify.sh (TOOLS/midentify.sh in the source code tree of MPlayer).

It will show information in a parseable format:

$  ./midentify.sh /data/myvid.flv 
ID_VIDEO_ID=0
ID_AUDIO_ID=1
ID_FILENAME=/data/myvid.flv
ID_DEMUXER=lavfpref
ID_VIDEO_FORMAT=VP6F
ID_VIDEO_BITRATE=0
ID_VIDEO_WIDTH=640
ID_VIDEO_HEIGHT=480

[,,,]

The good ol' "file" utility will often get the dimensions of a video file.

If you are not a terminal freak just open the file in Handbrake. It reports the image dimensions along with the file name. Works with mkv files.

Related