ffprobe:frame:count_number_of_frames
ffprobe - Frame - Count number of frames
ffprobe -v error -select_streams v:0 -count_packets -show_entries stream=nb_read_packets -of csv=p=0 input.mp4
NOTE:
- -v error - This hides “info” output (version info, etc) which makes parsing easier (but makes it harder if you ask for help since it hides important info).
- -count_frames - Counts the number of packets per stream and report it in the corresponding stream section.
- -select_streams v:0 - Select only the first video stream.
- -show_entries stream=nb_read_packets - Show only the entry for nb_read_frames.
- -of csv=p=0 - sets the output formatting.
- In this case it hides the descriptions and only shows the value.
Get frame count from video file metadata
ffprobe -select_streams v:0 -show_entries stream=nb_frames -of default=noprint_wrappers=1 input.mp4
WARNING: Fast, but often returns N/A, not reliable.
ffprobe -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 input.mp4
WARNING: Pretty slow, can take a minute for longer videos.
ffmpeg -i input.mp4 -map 0:v:0 -c copy -f null -
WARNING: Needs to fully decode video once, which is rather slow.
ffprobe/frame/count_number_of_frames.txt · Last modified: 2025/05/27 09:20 by peter