Spaces:
Sleeping
Sleeping
File size: 750 Bytes
9451ca9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import cv2
import os
def get_video_info(video_path):
try:
cap = cv2.VideoCapture(video_path)
fps = cap.get(cv2.CAP_PROP_FPS) or 24
frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
duration = frame_count / fps if fps > 0 else 0
cap.release()
return {'fps': fps, 'duration': duration, 'resolution': (width, height), 'frame_count': frame_count}
except:
return None
def validate_video_file(video_path):
if not video_path or not os.path.exists(video_path):
return False
info = get_video_info(video_path)
return info is not None and info['duration'] > 0
|