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 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:
To output in JSON or XML, add the appropriate option:
mediainfo --Output=JSON <input-file>
FFprobe, like FFMpeg, has so many options it can be daunting. However the basic usage is simple:
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:
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
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
-hide_banner -v 0:
ffprobe -hide_banner -v 0 -of json -show_format <input-file>
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.