|
37 | 37 | CutList, |
38 | 38 | CropRegion, |
39 | 39 | TimecodePair, |
| 40 | + TimecodeLike, |
40 | 41 | Interpolation, |
41 | 42 | ) |
42 | 43 | from scenedetect.video_stream import VideoStream, VideoOpenFailure |
@@ -136,8 +137,8 @@ def detect( |
136 | 137 | detector: SceneDetector, |
137 | 138 | stats_file_path: str | None = None, |
138 | 139 | show_progress: bool = False, |
139 | | - start_time: str | float | int | None = None, |
140 | | - end_time: str | float | int | None = None, |
| 140 | + start_time: TimecodeLike | None = None, |
| 141 | + end_time: TimecodeLike | None = None, |
141 | 142 | start_in_scene: bool = False, |
142 | 143 | ) -> SceneList: |
143 | 144 | """Perform scene detection on a given video `path` using the specified `detector`. |
@@ -170,18 +171,16 @@ def detect( |
170 | 171 | """ |
171 | 172 | video = open_video(video_path) |
172 | 173 | if start_time is not None: |
173 | | - start_time = video.base_timecode + start_time |
174 | | - video.seek(start_time) |
175 | | - if end_time is not None: |
176 | | - end_time = video.base_timecode + end_time |
| 174 | + video.seek(FrameTimecode(start_time, video.frame_rate)) |
| 175 | + end_timecode = FrameTimecode(end_time, video.frame_rate) if end_time is not None else None |
177 | 176 | # To reduce memory consumption when not required, we only add a StatsManager if we |
178 | 177 | # need to save frame metrics to disk. |
179 | 178 | scene_manager = SceneManager(StatsManager() if stats_file_path else None) |
180 | 179 | scene_manager.add_detector(detector) |
181 | 180 | scene_manager.detect_scenes( |
182 | 181 | video=video, |
183 | 182 | show_progress=show_progress, |
184 | | - end_time=end_time, |
| 183 | + end_time=end_timecode, |
185 | 184 | ) |
186 | 185 | if scene_manager.stats_manager is not None: |
187 | 186 | scene_manager.stats_manager.save_to_csv(csv_file=stats_file_path) |
|
0 commit comments