From d8155de4bd71fa1207b77501855b1328eb98e274 Mon Sep 17 00:00:00 2001 From: Mokshith Voodarla Date: Sat, 27 Jan 2024 16:55:16 -0800 Subject: [PATCH] feat: fix typing on scene detector --- video_scene_detection/main.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/video_scene_detection/main.py b/video_scene_detection/main.py index 08f9394..b4cae2f 100644 --- a/video_scene_detection/main.py +++ b/video_scene_detection/main.py @@ -31,7 +31,7 @@ class Scene(BaseModel): metadata=model_metadata, ) def scene_detection( - video: sieve.Video, + video: sieve.File, threshold: float = 27.0, adaptive_threshold: bool = False, ) -> Scene: @@ -46,6 +46,11 @@ def scene_detection( from scenedetect.scene_manager import SceneManager from scenedetect.video_manager import VideoManager + import cv2 + cap = cv2.VideoCapture(video.path) + fps = cap.get(cv2.CAP_PROP_FPS) + cap.release() + video_manager = VideoManager([video.path]) scene_manager = SceneManager() if adaptive_threshold: @@ -72,8 +77,8 @@ def scene_detection( ) ) - start_time_in_seconds = scene[0].get_frames() / video.fps - end_time_in_seconds = scene[1].get_frames() / video.fps + start_time_in_seconds = scene[0].get_frames() / fps + end_time_in_seconds = scene[1].get_frames() / fps yield Scene( start_seconds=start_time_in_seconds, end_seconds=end_time_in_seconds,