File size: 358 Bytes
830489a
 
9560049
 
830489a
 
 
 
 
 
 
 
 
 
 
9560049
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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