How to identify video formats from command line on Linux

If you want to know what video/audio codec are used for the video file you downloaded from somewhere, you can play the video itself. Most media player software such as VLC or MPlayer can display properties of a video file being played. However, there are command-line utilities that allow you to determine video properties quickly.

In this tutorial, I will describe how to check video formats from the command line on Linux.

Method One

The first method to determine video properties is by using ExifTool, which is a comprehensive media metadata viewer and editor. Using ExifTool, you can look up the metadata of a given video file easily.

$ exiftool input.mp4
ExifTool Version Number         : 8.60
File Name                       : input.mp4
Directory                       : .
File Size                       : 168 MB
File Modification Date/Time     : 2012:05:15 11:19:04-04:00
File Permissions                : rw-rw-r--
File Type                       : MP4
MIME Type                       : video/mp4
Major Brand                     : MP4 v2 [ISO 14496-14]
Minor Version                   : 0.0.0
Compatible Brands               : isom, mp42
Movie Header Version            : 0
Create Date                     : 2012:05:14 15:18:50
Modify Date                     : 2012:05:14 15:18:50
Time Scale                      : 600
Duration                        : 0:56:32
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 3
Track Header Version            : 0
Track Create Date               : 0000:00:00 00:00:00
Track Modify Date               : 2012:05:14 15:18:51
Track ID                        : 1
Track Duration                  : 0:56:32
Track Layer                     : 0
Track Volume                    : 0.00%
Image Width                     : 960
Image Height                    : 720
Graphics Mode                   : srcCopy
Op Color                        : 0 0 0
Compressor ID                   : avc1
Source Image Width              : 960
Source Image Height             : 720
X Resolution                    : 72
Y Resolution                    : 72
Bit Depth                       : 24
Video Frame Rate                : 6
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 2012:05:14 15:18:51
Media Modify Date               : 2012:05:14 15:18:51
Media Time Scale                : 44100
Media Duration                  : 0:56:32
Media Language Code             : und
Handler Description             : IsoMedia File Produced by Google, 5-11-2011
Balance                         : 0
Audio Format                    : mp4a
Audio Channels                  : 2
Audio Bits Per Sample           : 16
Audio Sample Rate               : 44100
Handler Type                    : Metadata
Handler Vendor ID               : Apple
Movie Data Size                 : 175021210
Avg Bitrate                     : 413 kbps
Image Size                      : 960x720
Rotation                        : 0

Method Two

Another way to identify video formats is to use tovid command-line tool, which is a command-line tool for creating DVDs. tovid can identify video formats as well.

One problem of ExifTool is that the metadata accessed by the tool may be inaccurate or sometimes misleading. Unlike ExifTool, tovid actually probes an input video file (by using MPlayer) to obtain accurate frame rate and video rate.

To install tovid on Ubuntu or Linux Mint:

$ sudo apt-get install tovid

To install tovid on other Linux distros, you can install it from source.

To find out video attributes with tovid, run it as follows.

$ tovid id input.mp4
Read options from /home/dev/.tovid/tovid.ini:

tovid id
Identify video files
Version 0.33
Analyzing file: 'input.mp4'...
               File: input.mp4
              Width: 960 pixels
             Height: 720 pixels
       Aspect ratio: 1.33:1
             Frames: 20357
           Duration: 00:56:32 hours/mins/secs
          Framerate: 6.000 frames per second
       Video format: H264
      Video bitrate: 288536 bits per second
Audio track 1 (Stream 0.1, AID 0):
              Codec: aac
            Bitrate: 124000 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.

Method Three

You can also directly use MPlayer from the command line to get information about a video.

$ mplayer -vo null -ao null -identify -frames 0 input.mp4
MPlayer svn r34540 (Ubuntu), built with gcc-4.7 (C) 2000-2012 MPlayer Team
Playing input.mp4.
libavformat version 53.21.0 (external)
Mismatching header version 53.19.0
libavformat file format detected.
[lavf] stream 0: video (h264), -vid 0
[lavf] stream 1: audio (aac), -aid 0, -alang und
VIDEO:  [H264]  960x720  24bpp  6.000 fps  288.5 kbps (35.2 kbyte/s)
Clip info:
 major_brand: mp42
 minor_version: 0
 compatible_brands: isommp42
 creation_time: 2012-05-14 15:18:50
ID_CLIP_INFO_VALUE3=2012-05-14 15:18:50
Load subtitles in ./
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 53.35.0 (external)
Mismatching header version 53.32.2
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, s16le, 124.1 kbit/8.80% (ratio: 15518->176400)
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
AO: [null] 44100Hz 2ch s16le (2 bytes per sample)

Method Four

If you have installed FFmpeg on your system, you can check video codec information from the command line with FFmpeg as follows.

$ ffmpeg -i input.mp4
ffmpeg -i storm.mp4
ffmpeg version 0.8.6-6:0.8.6-0ubuntu0.12.10.1, Copyright (c) 2000-2013 the Libav developers
  built on Apr  2 2013 17:02:16 with gcc 4.7.2
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'storm.mp4':
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2012-05-14 15:18:50
  Duration: 00:56:32.85, start: 0.000000, bitrate: 414 kb/s
    Stream #0.0(und): Video: h264 (High), yuv420p, 960x720, 288 kb/s, 6 fps, 6 tbr, 12 tbn, 12 tbc
      creation_time   : 1970-01-01 00:00:00
    Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 124 kb/s
      creation_time   : 2012-05-14 15:18:51
Download this article as ad-free PDF (made possible by your kind donation): 
Download PDF

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

5 thoughts on “How to identify video formats from command line on Linux

    • Mediainfo is badly designed, and just plain broken. All of the fancy display features either don't work, or don't work as "documented" (being rather kind to call that man page documentation).

  1. Also effective are the mkvtoolnix tools: mkvinfo and mkvmerge -i which both work on far more media containers than just Matroska.

Leave a comment

Your email address will not be published. Required fields are marked *