Get Video Frame Rate using FFmpeg

Get Video Frame Rate using FFmpeg

FFmpeg provides command-line tools for inspecting multimedia files and extracting information from individual streams. The frame rate is an important video property that indicates how many frames are displayed per second. Checking the frame rate can help when validating media properties, configuring encoding parameters, or preparing videos for further processing. This tutorial explains how to get the video frame rate using FFmpeg.

The ffprobe utility can inspect a media file and retrieve the frame rate reported by its video stream.

Download a sample video file for testing:

curl -sSo test.mp4 https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/big_buck_bunny.mp4

The video frame rate can be retrieved with the following command:

ffprobe -v error -select_streams v:0 -show_entries stream=r_frame_rate -of csv=p=0 test.mp4

The command produces:

24/1

The result 24/1 represents a frame rate of 24 frames per second (FPS).

Command breakdown:

  • ffprobe - analyzes multimedia files and extracts information about their streams.
  • -v error - suppresses informational and diagnostic output, displaying only errors.
  • -select_streams v:0 - selects the first video stream in the input file.
  • -show_entries stream=r_frame_rate - asks ffprobe to return the frame rate property of the selected video stream.
  • -of csv=p=0 - uses CSV formatting while excluding the field name and surrounding output information.
  • test.mp4 - specifies the video file to inspect.

Leave a Comment

Cancel reply

Your email address will not be published.