Skip to content

Instantly share code, notes, and snippets.

@talhaahussain
Last active June 14, 2024 18:33
Show Gist options
  • Save talhaahussain/4502fb022c3a58b34cec7db146da52c9 to your computer and use it in GitHub Desktop.
Save talhaahussain/4502fb022c3a58b34cec7db146da52c9 to your computer and use it in GitHub Desktop.
video_to_image_seq.py -- A Python function to convert a video to a sequence of images. Depends on OpenCV. See the original and an application here: https://github.com/talhaahussain/grappling-pose-identification/
import cv2
def split_video_into_frames(filename):
frames = []
cap = cv2.VideoCapture(filename)
fps = cap.get(cv2.CAP_PROP_FPS)
success = 1
while success:
success, frame = cap.read()
if success:
frames.append(frame)
cap.release()
return frames, fps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment