How to get the media files metadata using command line on Linux

neotam Avatar

How to get the media files metadata using command line on Linux
Posted on :

Tags :


Metadata is data about data. When it comes to media such as images, audio and video files, metadata provides the information about media. Metadata often times embedded into multimedia files and sometimes stored into a separate file.

There are different types of metadata,

  • Descriptive Metadata
  • Technical Metadata
  • Rights Metadata
  • Administrative Metadata
  • Preservation metadata
  • Structural Metadata

Descriptive Metadata

Descriptive metadata is the data that is added to images or videos media files by creator or photographer usually though software like Photoshop, GIMP or krita etc.

Descriptive metadata include location, author name, comments and notes etc. This descriptive meta data is useful for search that is even used by search engines like Google, Bing to index images according to descriptive metadata such that they are searchable.

Technical Metadata

As the name implies technical metadata provides the technical information such as camera details, shutter speed, DPI, files size and image format and software that was used to create the image etc. This metadata is typically autogenerated by software or camera devices

Rights Metadata

Images and media files also encode the rights related meta data such as copyright status, author and licences related to media

Preservation Metadata

This metadata is useful to determine weather file is has been corrupted or lost

Structural Metadata

This metadata provides information where file is located in sequence, hierarch or file structure.

Viewing Metadata

Use file command to print the file type on linux

file meidafile.mp3

To get the mime type

file -i rec_started.mp3

Print the meta data of audio files using ffmp3g command

ffmpeg -i media.mp3

Print the meta data of selected file in JSON using ffmpeg

ffprobe -loglevel 0 -print_format json -show_format -show_streams <imput-media.{mp3,avi,mp4,mkv}>

decoding above command line arguments

-loglevel controls the amount of information to produce

-print_format: Supported formats are JSON, XML, CSV, and INI

-show_format: If this option is provided, container format of input media is provided

-show_streams: Information about each media stream in the input multimedia stream is produced with separate section in the output

Use media info to print the information in the pretty manner

mediainfo <mediainputfile>

Print the file information using sox command

soxi <mediainput.{mp3,wav}>


sox --i <mediainput>

ImageMagic utility comes with the tool “identify” that can be used to find the metadata of images. install the image magic on different distributions as follows

#Arch Linux
$ sudo pacman -S imagemagick

#On Debian, Ubuntu, Linux Mint
$ sudo apt install imagemagick

#On Fedora
$ sudo dnf install imagemagick

$ sudo zypper install ImageMagick


Now, we can identify the metadata of an image as follows

identify image.png 

Verbose parameter provides the detailed information,

identify -verbose image.png 

Using Exif Tool

Exif is the command line utility which can be used to view and edit EXIF information of an image

Exif stands for “Exchangeable Image File Format” is the JPEG file written on to the storage devices when pictures are taken with camera (or smartphone). EXIF data includes the information about date and time, camera settings, license and copyright, geolocation and Colour space etc.

Install the exif tool

sudo apt install exif

Use exif command to view metadata

exif image.jpg 

Leave a Reply

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