How to Get Video Frame Rate with FFprobe
This guide explains how to extract a video’s frame rate using
ffprobe and format the output as a clean, numeric value
suitable for scripting. By default, ffprobe prints verbose
metadata banners and formatting wrappers, but using targeted
stream-selection and output-formatting flags allows you to isolate and
display only the frame rate number.
Get Frame Rate as a Clean Fraction
By default, media containers store frame rates as rational numbers
(such as 30/1 or 30000/1001). To output this
raw fractional rate with no headers or keys, run:
ffprobe -v error -select_streams v:0 -show_entries stream=r_frame_rate -of default=noprint_wrappers=1:nokey=1 input.mp4Alternatively, you can use the CSV output format for a more concise syntax:
ffprobe -v error -select_streams v:0 -show_entries stream=r_frame_rate -of csv=p=0 input.mp4Command Breakdown:
-v error: Suppresses informational logs and banners, ensuring only errors and requested data appear.-select_streams v:0: Targets only the first video stream, ignoring audio or subtitle tracks.-show_entries stream=r_frame_rate: Reads the real base frame rate property from the stream.-of default=noprint_wrappers=1:nokey=1: Removes section headers ([STREAM]...[/STREAM]) and the key prefix (r_frame_rate=), printing only the value.
Get Frame Rate as a Decimal Value
Because ffprobe outputs container frame rates as
fractions, you can pipe the result into standard command-line tools like
bc or awk to convert it into a standard
decimal format (e.g., 29.97 or 23.976).
Using bc:
ffprobe -v error -select_streams v:0 -show_entries stream=r_frame_rate -of csv=p=0 input.mp4 | bc -lTo round the output to two decimal places:
ffprobe -v error -select_streams v:0 -show_entries stream=r_frame_rate -of csv=p=0 input.mp4 | awk -F/ '{ printf "%.2f\n", $1/$2 }'r_frame_rate vs.
avg_frame_rate
Depending on the file encoding, you may choose between two different stream properties:
r_frame_rate: The lowest common denominator frame rate. This represents the intended playback rate for constant frame rate (CFR) files.avg_frame_rate: The average frame rate calculated across all frames. This is more accurate for variable frame rate (VFR) content.
To query avg_frame_rate instead, replace the property
name in the command:
ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of csv=p=0 input.mp4