Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Total number of frames with ffmpeg [duplicate]

How do I find the total number of frames in a video with ffmpeg?

like image 855
Utkarsh Sinha Avatar asked Nov 12 '10 16:11

Utkarsh Sinha


2 Answers

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.

like image 54
Jason B Avatar answered Nov 11 '22 05:11

Jason B


If you are invoking ffmpeg programmatically then the OpenCV library provides a convenient python/c++ interface for accessing video properties -

http://opencv.willowgarage.com/documentation/python/reading_and_writing_images_and_video.html#getcaptureproperty

Alternatively you could try to parse the output from ffprobe which comes bundled with ffmpeg and calculate total frame based on duration and FPS.

like image 1
omatica Avatar answered Nov 11 '22 06:11

omatica