count_frames
- lib.video.count_frames(filename, fast=False)
Count the number of frames in a video file
There is no guaranteed accurate way to get a count of video frames without iterating through a video and decoding every frame.
count_frames()can return an accurate count (albeit fairly slowly) or a possibly less accurate count, depending on thefastparameter. A progress bar is displayed.- Parameters:
filename (str) – Full path to the video to return the frame count from.
fast (bool, optional) – Whether to count the frames without decoding them. This is significantly faster but accuracy is not guaranteed. Default:
False.
- Returns:
The number of frames in the given video file.
- Return type:
int
Example
>>> filename = "/path/to/video.mp4" >>> frame_count = count_frames(filename)