import cv2 def extract_frames(video_path, interval=30): cap = cv2.VideoCapture(video_path) # directly use the path frames = [] i = 0 while cap.isOpened(): ret, frame = cap.read() if not ret: break if i % interval == 0: frames.append(frame) i += 1 cap.release() return frames