Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What is the best way to obtain information as bitrate, framerate, width/height of an movie file (in my case .avi) from the command line? I am looking for a basic tool that works similarly as ImageMagicks identify.

Running mplayer already gives this information (but also does a lot more):

VIDEO: [FMP4] 800x711 24bpp 25.000 fps 1320.9 kbps (161.2 kbyte/s)

Is there a way to make mplayer only give this output (I did not find it in the man) or is there another standard bash-command to obtain the same information?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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:

# 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

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.


$ midentify some_random.avi 
share|improve this answer
midentify is not installed on this system, mplayer movie.avi -identify gives this kind of output, but also plays the movie. –  Bernhard Jan 14 '12 at 11:28
It's just a wrapper script, I edited some information in - you could adapt that mplayer command to suit your exact needs. –  Mat Jan 14 '12 at 11:32
Your script does exactly what I need. Also via ssh without X11 forwarding whatsoever. Thank you! –  Bernhard Jan 14 '12 at 11:51
Edited to better reflect that it's not my script, it comes with the mplayer source code. –  Mat Jan 14 '12 at 11:54
Nice thanks but it shows me video bitrate of 0 (this is MPEG4 AVC VBR). :-( –  lzap Apr 27 '13 at 17:21

You can use the file command.

share|improve this answer
Easy and fast solution, basically what I was looking for. Only bitrate information is missing here. –  Bernhard Jan 14 '12 at 11:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.