Spaces:
Runtime error
Runtime error
Download modules/frame_extractor.py from Adityasv99/ClipForge-AI: direct link, hf CLI and curl.
- Browser
- Download file 409 Bytes
-
https://huggingface.co/spaces/Adityasv99/ClipForge-AI/resolve/main/modules/frame_extractor.py
- Command line
-
hf download hf://spaces/Adityasv99/ClipForge-AI/modules/frame_extractor.py
-
curl -L -o frame_extractor.py https://huggingface.co/spaces/Adityasv99/ClipForge-AI/resolve/main/modules/frame_extractor.py
409 Bytes
| import cv2 | |
| import os | |
| OUTPUT_DIR = "assets/outputs" | |
| os.makedirs(OUTPUT_DIR, exist_ok=True) | |
| def extract_frame(video_path): | |
| cap = cv2.VideoCapture(video_path) | |
| success, frame = cap.read() | |
| cap.release() | |
| if not success: | |
| raise ValueError("Could not read frame from video.") | |
| frame_path = os.path.join(OUTPUT_DIR, "frame.jpg") | |
| cv2.imwrite(frame_path, frame) | |
| return frame_path | |