Skip to content

Commit

Permalink
feat: fix typing on scene detector
Browse files Browse the repository at this point in the history
  • Loading branch information
mvoodarla committed Jan 28, 2024
1 parent 95c7530 commit d8155de
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions video_scene_detection/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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,
Expand Down

0 comments on commit d8155de

Please sign in to comment.