Extract Video Metadata in Flat Format with FFmpeg

This article explains how to use FFmpeg’s companion tool, ffprobe, to extract video metadata and output it in a flat, easy-to-parse format. By using the flat print format, you can easily read video properties like duration, resolution, and codecs directly in command-line scripts.

To extract video metadata in a flat format, you need to use the ffprobe command-line utility, which is installed automatically alongside FFmpeg.

Run the following command in your terminal:

ffprobe -v error -show_format -show_streams -print_format flat input.mp4

Parameter Breakdown

Saving the Output to a File

If you want to save the flat metadata to a text file for later use, redirect the output using the > operator:

ffprobe -v error -show_format -show_streams -print_format flat input.mp4 > metadata.txt

Filtering Specific Metadata

The flat format makes it easy to filter for specific properties using standard command-line tools like grep. For example, to find only the width and height of the video, run:

ffprobe -v error -show_streams -print_format flat input.mp4 | grep -E 'width|height'