OWolf

2024-09-24 Video Production

Extracting Metadata from a Video File Using FFprobe

By O. Wolfson

When working with video files, it's often necessary to retrieve detailed metadata such as codec information, resolution, frame rate, and audio settings. A quick and effective way to gather this information is by using ffprobe, a tool included with FFmpeg.

To extract metadata from a video file and save it in JSON format, use the following command:

bash
ffprobe -v quiet -print_format json -show_format -show_streams input_video.mp4 > input_video.metadata.json

Breakdown of the Command:

  • ffprobe: The tool to extract metadata from multimedia files.
  • -v quiet: Suppresses unnecessary output, showing only the metadata.
  • -print_format json: Outputs the metadata in JSON format, making it easy to read and parse.
  • -show_format -show_streams: Displays both the overall file format and specific stream information (such as video and audio codec details).
  • input_video.mp4: The input video file from which you want to extract metadata.
  • > input_video.metadata.json: Saves the output in a JSON file for later use.

This command generates a JSON file containing useful information about your video, such as codec, resolution, bit rate, duration, and more. The metadata is valuable for verifying file properties, troubleshooting, or preparing the video for further processing.