How To Get Media Info From Raspberry Pi Command Line

2

Whether you are using your Raspberry Pi to play media or create it you may have a need to examine the properties of various bits of media. This might include MP3, MP4 or JPG files.

There is an easy way to examine the properties using a utility called “MediaInfo”. MediaInfo is available for a wide range of operating systems and languages and I use it on my Windows 7 PC.

MediaInfo can provide lots of detail including :

  • General : title, author, director, album, track number, date, duration …
  • Video: format, codec id, aspect, frame rate, bit rate …
  • Audio: format, codec id, sample rate, channels, language, bit rate …

Install MediaInfo

To install the package you can use the command :

sudo apt-get install -y mediainfo

Using MediaInfo

To examine an MP3 file you can use :

mediainfo /home/pi/test.mp3

where “/home/pi/test.mp3” is the path to the file. If you are already in the required directory you can simply type :

mediainfo test.mp3

Here is an example output from an MP3 :

Mediainfo Example - Audio

It’s equally easy to grab information from video files :

mediainfo myvideo.mp4

Here is an example output from an avi file :

Mediainfo Example - Video

This output can re-directed to a text file using :

mediainfo example.mp4 > info.txt

Supported Formats

Mediainfo supports most of the formats you are likely to need :

  • Matroska (mkv/mka/mks)
  • Ogg (ogg/ogm)
  • Riff (avi/wav)
  • Mpeg 1&2 container (mpeg/mpg/vob)
  • Mpeg 4 container (mp4)
  • Mpeg video specific (mpgv/mpv/m1v/m2v)
  • Mpeg audio specific (mp2/mp3)
  • Windows Media (asf/wma/wmv)
  • Quicktime (qt/mov)
  • Real (rm/rmvb/ra)
  • DVD-Video (ifo)
  • AC3 (ac3)
  • DTS (dts)
  • AAC (aac)
  • Monkey’s Audio (ape/mac)
  • Flac (flac)
  • CDXA, like Video-CD (dat)
  • Apple/SGI (aiff/aifc)
  • Sun/NeXT (au)
  • Amiga IFF/SVX8/SV16 (iff)
  • Ensoniq PARIS (paf)
  • Sound Designer 2 (sd2)
  • Berkeley/IRCAM/CARL (irca)
  • SoundFoundry WAVE 64 (w64)
  • Matlab (mat)
  • Portable Voice format (pvf)
  • FastTracker2 Extanded (xi)
  • Midi Sample dump Format (sds)
  • Audio Visual Research (avr)

Additional information on the metadata items that can be extracted from these file types is detailed on the Mediainfo Formats page.

If you want some test media for your Pi then you can grab some decent free, legal video from the Big Buck Bunny download site.

Share.

2 Comments

  1. Jury D'Ambros on

    this is the full output i got:

    sudo apt-get install -y mediainfo
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Package mediainfo is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    E: Package ‘mediainfo’ has no installation candidate

Leave A Reply