Download video_utils.py from UmReh/SachAI: direct link, hf CLI and curl.
- Browser
- Download file 368 Bytes
-
https://huggingface.co/spaces/UmReh/SachAI/resolve/main/video_utils.py
- Command line
-
hf download hf://spaces/UmReh/SachAI/video_utils.py
-
curl -L -o video_utils.py https://huggingface.co/spaces/UmReh/SachAI/resolve/main/video_utils.py
368 Bytes
| import cv2 | |
| def extract_frames(video_path, frame_skip=7): | |
| cap = cv2.VideoCapture(video_path) | |
| frames = [] | |
| count = 0 | |
| while cap.isOpened(): | |
| ret, frame = cap.read() | |
| if not ret: | |
| break | |
| if count % frame_skip == 0: | |
| frames.append(frame) | |
| count += 1 | |
| cap.release() | |
| return frames |