Skip to content

Instantly share code, notes, and snippets.

@victormurcia
Created October 20, 2022 21:46
Show Gist options
  • Select an option

  • Save victormurcia/734b8b9cec8120c3b2adb0da9f7bcb64 to your computer and use it in GitHub Desktop.

Select an option

Save victormurcia/734b8b9cec8120c3b2adb0da9f7bcb64 to your computer and use it in GitHub Desktop.
count frames in mp4 file
#Determine number of frames in video
def count_frames(video_file):
"""
Args:
video_file: (str) path to .MP4 video file
Returns:
nFrames: (int) Number of frames in mp4
"""
cap = cv2.VideoCapture(video_file)
length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
return(length)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment