How to identify video formats from command line on Linux

Last updated on November 27, 2020 by Dan Nanni

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: exiftool

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: tovid

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

One problem of previously mentioned 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
http://tovid.wikia.com
--------------------------------
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: mplayer

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.
ID_VIDEO_ID=0
[lavf] stream 0: video (h264), -vid 0
ID_AUDIO_ID=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
ID_CLIP_INFO_NAME0=major_brand
ID_CLIP_INFO_VALUE0=mp42
 minor_version: 0
ID_CLIP_INFO_NAME1=minor_version
ID_CLIP_INFO_VALUE1=0
 compatible_brands: isommp42
ID_CLIP_INFO_NAME2=compatible_brands
ID_CLIP_INFO_VALUE2=isommp42
 creation_time: 2012-05-14 15:18:50
ID_CLIP_INFO_NAME3=creation_time
ID_CLIP_INFO_VALUE3=2012-05-14 15:18:50
ID_CLIP_INFO_N=4
Load subtitles in ./
ID_FILENAME=input.mp4
ID_DEMUXER=lavfpref
ID_VIDEO_FORMAT=H264
ID_VIDEO_BITRATE=288536
ID_VIDEO_WIDTH=960
ID_VIDEO_HEIGHT=720
ID_VIDEO_FPS=6.000
ID_VIDEO_ASPECT=0.0000
ID_AUDIO_FORMAT=MP4A
ID_AUDIO_BITRATE=124144
ID_AUDIO_RATE=44100
ID_AUDIO_NCH=2
ID_START_TIME=0.00
ID_LENGTH=3392.85
ID_SEEKABLE=1
ID_CHAPTERS=0
==========================================================================
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)
==========================================================================
ID_VIDEO_CODEC=ffh264
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, s16le, 124.1 kbit/8.80% (ratio: 15518->176400)
ID_AUDIO_BITRATE=124144
ID_AUDIO_RATE=44100
ID_AUDIO_NCH=2
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
AO: [null] 44100Hz 2ch s16le (2 bytes per sample)
ID_AUDIO_CODEC=ffaac

Method Four: ffmpeg

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':
  Metadata:
    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
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 124 kb/s
    Metadata:
      creation_time   : 2012-05-14 15:18:51

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean