Senko Rašić

Inspecting media files

A short tutorial on how to inspect audio and video files to check codecs, formats and other metadata.

When working with video or audio files, the first step is usually to inspect the source material. Two popular open-source tools for this are ffprobe (part of the ffmpeg project), and mediainfo.

While ffmpeg is more capable, supporting basically everything ffmpeg does, mediainfo is a bit more user friendly, and also has GUI versions that some people may prefer.

Both tools support showing the information to the user or outputting it in several formats suitable for other programs, such as JSON or XML.

Both tools support Linux, macOS and Windows operating systems.

Mediainfo

mediainfo gui

Mediainfo can be installed using a package manager on Linux (CLI and GUI), Homebrew (CLI) or App Store (GUI) on macOS, or by downloading directly from MediaArea official site.

The command-line usage is simple:

    mediainfo <input-file>

To output in JSON or XML, add the appropriate option:

    mediainfo --Output=JSON <input-file>

ffprobe

FFprobe, like FFMpeg, has so many options it can be daunting. However the basic usage is simple:

    ffprobe <input-file>

FFprobe can also use any input protocol supported by ffmpeg, such as HTTP, RTSP, RTMP and others. As an example, here’s how to inspect an MP3 network stream from an internet radio station:

    ffprobe https://www.musicbox.com.hr/stream/2faa5a59-8af8-4e17-89f4-4c0101ff1077

For a more detailed output about the file format or streams within the file:

    ffprobe -show_format -show_streams <input-file>

If needed, you can also get information on every frame of the content with:

    ffprobe -show_frames <input-file>

Change the output format to JSON, XML, INI or CSV with -of (-print_format) option:

    ffprobe -of json -show_format <input-file>

When using the output in another program, you’ll likely want to suppress the info/copyright banner and verbose information with -hide_banner -v 0:

    ffprobe -hide_banner -v 0 -of json -show_format <input-file>

Further info

While the above covers my needs in 95% of the cases, these tools, especially ffmpeg, are more powerful. If you need to dig deeper, start with --help option and be sure to check the online manuals for both ffprobe and MediaInfo.

Senko Rašić
Audio/Video and Real-Time Web consultant
Read more articles

Have a project I could help with?

Contact me