Get number of frames in clip with Moviepy

Maurdekye picture Maurdekye · Jun 3, 2016 · Viewed 7.4k times · Source

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.

Answer

Maurdekye picture Maurdekye · Jun 3, 2016

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)