@@ -193,42 +193,38 @@ def split_video_mkvmerge(
193193 if not scene_list :
194194 return 0
195195
196- logger .info ("Splitting video with mkvmerge, output path template:\n %s" , output_file_template )
197- if output_dir :
198- logger .info ("Output folder:\n %s" , output_file_template )
199-
200196 if video_name is None :
201197 video_name = Path (input_video_path ).stem
202198
203- ret_val = 0
204-
205199 # mkvmerge doesn't support adding scene metadata to filenames. It always adds the scene
206200 # number prefixed with a dash to the filenames.
207201 template = Template (output_file_template )
208202 output_path = template .safe_substitute (VIDEO_NAME = video_name )
209203 if output_dir :
210204 output_path = Path (output_dir ) / output_path
211- output_path .parent .mkdir (parents = True , exist_ok = True )
212-
205+ Path (output_path ).parent .mkdir (parents = True , exist_ok = True )
206+ logger .info (f"Splitting video with mkvmerge, path template: { output_path } " )
207+
208+ call_list = ["mkvmerge" ]
209+ if not show_output :
210+ call_list .append ("--quiet" )
211+ call_list += [
212+ "-o" ,
213+ str (output_path ),
214+ "--split" ,
215+ "parts:%s"
216+ % "," .join (
217+ [
218+ "%s-%s" % (start_time .get_timecode (), end_time .get_timecode ())
219+ for start_time , end_time in scene_list
220+ ]
221+ ),
222+ input_video_path ,
223+ ]
224+ total_frames = scene_list [- 1 ][1 ].get_frames () - scene_list [0 ][0 ].get_frames ()
225+ processing_start_time = time .time ()
226+ ret_val = 0
213227 try :
214- call_list = ["mkvmerge" ]
215- if not show_output :
216- call_list .append ("--quiet" )
217- call_list += [
218- "-o" ,
219- str (output_path ),
220- "--split" ,
221- "parts:%s"
222- % "," .join (
223- [
224- "%s-%s" % (start_time .get_timecode (), end_time .get_timecode ())
225- for start_time , end_time in scene_list
226- ]
227- ),
228- input_video_path ,
229- ]
230- total_frames = scene_list [- 1 ][1 ].get_frames () - scene_list [0 ][0 ].get_frames ()
231- processing_start_time = time .time ()
232228 # TODO: Capture stdout/stderr and show that if the command fails.
233229 ret_val = invoke_command (call_list )
234230 if show_output :
0 commit comments