How do I find the total number of frames in a video with ffmpeg?
Asked
Active
Viewed 2.2k times
2 Answers
9
Take a look at this answer. The problem is that the exact number of frames is often not stored in metadata and can only be truly found (not estimated) by decoding the file and figuring out how many there are. If you only need an estimate, you can just use the framerate and duration provided by ffmpeg -i <filename>
to estimate.
-
Which part of the ffmpeg -i output would the framerate and duration be, and how would you get the number of frames from that? – Superdooperhero Jul 16 '17 at 19:25
1
If you are invoking ffmpeg programmatically then the OpenCV library provides a convenient python/c++ interface for accessing video properties -
Alternatively you could try to parse the output from ffprobe which comes bundled with ffmpeg and calculate total frame based on duration and FPS.

omatica
- 194
- 2
- 8
-
-
@UtkarshSinha, did you find command line way for total number of frames? – gaussblurinc Mar 30 '14 at 14:14
-
I did not - I could get a best guess/estimate, but not an exact number. – Utkarsh Sinha Apr 05 '14 at 13:13
-
@gaussblurinc Here: https://stackoverflow.com/questions/2017843/fetch-frame-count-with-ffmpeg – Alexis Wilke Dec 06 '20 at 19:42