Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get number of frames in clip with Moviepy

You would think this would be such a simple operation, but there is nothing in the documentation about how to get the number of frames in a video clip. The only way I can think of is to use iter_frames() and just count the frames out one by one, but for some reason it takes almost a full second to iterate through 15 frames of video, even if i'm not performing any action on them.

like image 492
Maurdekye Avatar asked Jun 03 '16 20:06

Maurdekye


1 Answers

As it turns out moviepy doesn't save individual frame data, so it doesn't store the exact frame count. Here is the best way I found to get an approximation:

frames = int(clip.fps * clip.duration)
like image 87
Maurdekye Avatar answered Oct 10 '22 02:10

Maurdekye