@@ -160,19 +160,16 @@ def _load_scenes(context: CliContext) -> ty.Tuple[SceneList, CutList]:
160160 csv_headers = next (file_reader )
161161 if context .load_scenes_column_name not in csv_headers :
162162 csv_headers = next (file_reader )
163- # Check to make sure column headers are present
163+ # Check to make sure column headers are present and then load the data.
164164 if context .load_scenes_column_name not in csv_headers :
165165 raise ValueError ("specified column header for scene start is not present" )
166-
167166 col_idx = csv_headers .index (context .load_scenes_column_name )
168-
169167 cut_list = sorted (
170168 FrameTimecode (row [col_idx ], fps = context .video_stream .frame_rate ) - 1
171169 for row in file_reader
172170 )
173- # `SceneDetector` works on cuts, so we have to skip the first scene and use the first frame
174- # of the next scene as the cut point. This can be fixed if we used `SparseSceneDetector`
175- # but this part of the API is being reworked and hasn't been used by any detectors yet.
171+ # `SceneDetector` works on cuts, so we have to skip the first scene and place the first
172+ # cut point where the next scenes starts.
176173 if cut_list :
177174 cut_list = cut_list [1 :]
178175
@@ -182,14 +179,12 @@ def _load_scenes(context: CliContext) -> ty.Tuple[SceneList, CutList]:
182179 cut_list = [cut for cut in cut_list if cut > context .start_time ]
183180
184181 end_time = context .video_stream .duration
185- if context .end_time is not None or context .duration is not None :
186- if context .end_time is not None :
187- end_time = context .end_time
188- elif context .duration is not None :
189- end_time = start_time + context .duration
190- end_time = min (end_time , context .video_stream .duration )
182+ if context .end_time is not None :
183+ end_time = min (context .end_time , context .video_stream .duration )
184+ elif context .duration is not None :
185+ end_time = min (start_time + context .duration , context .video_stream .duration )
186+
191187 cut_list = [cut for cut in cut_list if cut < end_time ]
188+ scene_list = get_scenes_from_cuts (cut_list = cut_list , start_pos = start_time , end_pos = end_time )
192189
193- return get_scenes_from_cuts (
194- cut_list = cut_list , start_pos = start_time , end_pos = end_time
195- ), cut_list
190+ return (scene_list , cut_list )
0 commit comments