images_to_heartpulses/video to image.py

20 lines
487 B
Python

import cv2
# Open the video file
video = cv2.VideoCapture("take3.mp4")
# Get the video frame rate
frame_rate = video.get(cv2.CAP_PROP_FPS)
# Get the total number of frames in the video
total_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
# Extract 24 frames per second and save them as images
frame_number = 0
while True:
success, frame = video.read()
cv2.imwrite("frame2_{}.jpg".format(frame_number), frame)
frame_number += 1
# Release the video file
video.release()