Skip to content

Commit 3ee41b5

Browse files
committed
[bugfix] Fix CLI crash when running split-video --mkvmerge but no output directory was set
1 parent 709770a commit 3ee41b5

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

scenedetect/video_splitter.py

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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:

website/pages/changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,4 +622,6 @@ Both the Windows installer and portable distributions now include signed executa
622622
Development
623623
==========================================================
624624

625-
## PySceneDetect 0.6.6 (TBD)
625+
## PySceneDetect 0.6.6 (In Development)
626+
627+
- [bugfix] Fix crash when using `-m`/`--mkvmerge` flag with `split-video` command [#473](https://github.com/Breakthrough/PySceneDetect/issues/473)

0 commit comments

Comments
 (0)