Quickly Identify Video File Attributes
published 2009-11-03 · refreshed 2026-10-20 · tested on Ubuntu 26.04 · ffmpeg/ffprobe 8.0.1 · MediaInfo 26.01 · mkvtoolnix v97 · exiftool 13.50 · tags: cli, linux, multimedia, video
In 2009 the answer was mplayer -identify and the idvid script from the tovid suite. tovid is gone, mplayer is a niche install, and the tool that ships on every box with ffmpeg does the job better: ffprobe reads the actual streams, is fast, and prints in whatever shape a script needs. MediaInfo is the one to reach for when a human has to read the result.
ffprobe: the one-liner
ffprobe -hide_banner video.mp4
That prints the container, duration, overall bitrate and one line per stream, the way mplayer used to. For a fixed set of fields, ask for exactly those:
ffprobe -v error -show_entries format=duration,size,bit_rate:stream=index,codec_type,codec_name,width,height,r_frame_rate,sample_rate,channels -of default=noprint_wrappers=1 video.mp4
index=0
codec_name=h264
codec_type=video
width=320
height=240
r_frame_rate=25/1
index=1
codec_name=aac
codec_type=audio
sample_rate=44100
channels=1
duration=20.000000
size=494783
bit_rate=197913
-v error silences the banner and warnings, -show_entries picks the fields (format-level before the colon, stream-level after), -of default=noprint_wrappers=1 drops the [STREAM] brackets.
ffprobe in scripts
One line of CSV with the video stream only (-select_streams v:0):
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,width,height,r_frame_rate -of csv=p=0 video.mp4
h264,320,240,25/1
Everything as JSON, for jq or anything else:
ffprobe -v error -show_format -show_streams -of json video.mp4
Frame rates come as fractions (r_frame_rate=25/1, or 30000/1001 for 29.97 fps), and r_frame_rate is the stream’s nominal rate; avg_frame_rate is the measured average, which matters for variable-frame-rate screen captures.
MediaInfo: the readable version
sudo apt install mediainfo
mediainfo video.mp4
That prints General, Video and Audio sections with human units. --Inform templates give you one line per file, handy for a whole directory:
mediainfo --Inform="Video;%Format% %Width%x%Height% %FrameRate%fps %BitRate/String%" video.mp4
mediainfo --Inform="General;%Duration/String% %FileSize/String%" video.mp4
AVC 320x240 25.000fps 123 kb/s
20 s 0 ms 483 KiB
Matroska files
For .mkv, mkvmerge -i from mkvtoolnix lists tracks, chapters and attachments by track ID, which is also what you need for mkvextract and mkvpropedit:
mkvmerge -i video.mkv
File 'video.mkv': container: Matroska
Track ID 0: video (AVC/H.264/MPEG-4p10)
Track ID 1: audio (AAC)
Chapters: 3 entries
exiftool: metadata only
exiftool video.mp4
exiftool (package libimage-exiftool-perl) still works on video and is the fastest of the lot, but it reads the container’s metadata rather than probing the streams, so a mislabelled file will mislead it. Use it when you want creation dates, camera model or GPS from a phone recording; use ffprobe when you want the truth about the codec.
AS PUBLISHED, 2009
If you want to gain quick insight into the basic properties of a video file from the Linux command line, there’s a few really easy methods. The information you might be interested in are audio and video codecs, resolution, frame rates, bitrates, etc.
Using *mplayer*, you can see some basic information about a video file. For example, the following video is using the WMV3 video codec at the resolution of 1280×720 (720p), the bitrate of 3000 kbps, etc.
mplayer video.wmv -vo null -ao null -frames 0 2>&1 /dev/null | egrep "(VIDEO|AUDIO)"
VIDEO: [WMV3] 1280x720 24bpp 1000.000 fps 3000.0 kbps (366.2 kbyte/s)
AUDIO: 44100 Hz, 2 ch, s16le, 96.0 kbit/6.80% (ratio: 12003->176400)
The audio rate is shown to be 44100 Hz using 2-Channel stereo, but the codec is not listed. You can get additional information with the -identify option.
mplayer video.wmv -identify -vo null -ao null -frames 0 2>&1 /dev/null | egrep "(^ID|VIDEO|AUDIO)"
ID_AUDIO_ID=1
ID_VIDEO_ID=2
VIDEO: [WMV3] 1280x720 24bpp 1000.000 fps 3000.0 kbps (366.2 kbyte/s)
ID_CLIP_INFO_NAME0=name
ID_CLIP_INFO_VALUE0=
ID_CLIP_INFO_NAME1=author
ID_CLIP_INFO_VALUE1=
ID_CLIP_INFO_NAME2=copyright
ID_CLIP_INFO_VALUE2=
ID_CLIP_INFO_NAME3=comments
ID_CLIP_INFO_VALUE3=
ID_CLIP_INFO_N=4
ID_FILENAME=video.wmv
ID_DEMUXER=asf
ID_VIDEO_FORMAT=WMV3
ID_VIDEO_BITRATE=3000000
ID_VIDEO_WIDTH=1280
ID_VIDEO_HEIGHT=720
ID_VIDEO_FPS=1000.000
ID_VIDEO_ASPECT=1.7778
ID_AUDIO_FORMAT=353
ID_AUDIO_BITRATE=0
ID_AUDIO_RATE=0
ID_AUDIO_NCH=0
ID_LENGTH=2116.00
ID_VIDEO_ASPECT=1.7778
ID_VIDEO_CODEC=wmv9dmo
AUDIO: 44100 Hz, 2 ch, s16le, 96.0 kbit/6.80% (ratio: 12003->176400)
ID_AUDIO_BITRATE=96024
ID_AUDIO_RATE=44100
ID_AUDIO_NCH=2
ID_AUDIO_CODEC=ffwmav2
Another great tool for identifying video attributes is *idvid*. *idvid* comes with the *tovid* package, so be sure to install it from your repository. It is a bit slow, but the output is very clean and easy to interpret.
idvid video.wmv
--------------------------------
idvid
Video identification script
Part of the tovid suite, version 0.31
http://www.tovid.org
--------------------------------
Analyzing file: 'video.wmv'. This may take several minutes...
=========================================================
File: video.wmv
Width: 1280 pixels
Height: 720 pixels
Aspect ratio: 1.77:1
Frames: 63352
Duration: 00:35:13 hours/mins/secs
Framerate: 1000.000 frames per second
Video format: WMV3
Video bitrate: 3000000 bits per second
---------------------------
Audio track 1 (Stream 0.0, AID 0):
---------------------------
Codec: wmav2
Bitrate: 0000 bits per second
Sampling rate: 44100 Hz
=========================================================
Audio is compliant with the following formats:
Not compliant with (S)VCD or DVD
Video is compliant with the following formats:
Not compliant with (S)VCD or DVD
This video does not seem to be compliant with (S)VCD or DVD
standards. If you burn it to a video disc, it may not work.
=========================================================
Finally, another tool that works very well is *exiftool*. It’s available in the *libimage-exiftool-perl* package. The output is also very straight forward, and easy to interpret. It’s also a lot faster than *idvid* because the tool only displays metadata, which in some cases can be misleading.*Mplayer* and *tovid* actually probe the video, providing very accurate information at the cost of speed.
exiftool video.wmv
ExifTool Version Number : 7.30
File Name : video.wmv
Directory : .
File Modification Date/Time : 2009:04:20 09:21:58
File Type : WMV
MIME Type : video/x-ms-wmv
File ID : 12341234-1234-1234-1234-123412341234
File Size : 823200182
Creation Date : 2009:03:31 02:52:55Z
Data Packets : 102833
Play Duration : 35:16
Send Duration : 35:13
Preroll : 3000
Flags : 2
Min Packet Size : 8000
Max Packet Size : 8000
Max Bitrate : 3122812
Is VBR : False
Audio Codec Name : Windows Media Audio 9.2
Audio Codec Description : 96 kbps, 44 kHz, stereo 1-pass CBR
Video Codec Name : Windows Media Video 9
Video Codec Description : Professional
Audio Codec ID : Windows Media Audio V2 V7 V8 V9 / DivX audio (WMA) / Alex AC3 Audio
Audio Channels : 2
Audio Sample Rate : 44100
Stream Type : Video
Error Correction Type : No Error Correction
Time Offset : 0 s
Stream Number : 2
Image Width : 1280
Image Height : 720
Title :
Author :
Copyright :
Description :
Rating :
Image Size : 1280x720
As always, comments and additional tips are welcome!