Skip to content

Commit

Permalink
Fix bug caused when no scenes are detected and the split-video comman…
Browse files Browse the repository at this point in the history
…d is specified. Closes #79.
  • Loading branch information
Breakthrough committed Sep 23, 2018
1 parent 7af8b8f commit d70354b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 2 additions & 7 deletions scenedetect/cli/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,17 +419,12 @@ def process_input(self):
if not self.split_mkvmerge:
logging.warning(
'ffmpeg not found, falling back to fast copy mode (split-video -c/--copy).')
logging.info('Splitting input video%s using mkvmerge, output path template:\n %s',
's' if len(video_paths) > 1 else '', output_file_prefix)
split_video_mkvmerge(video_paths, scene_list, output_file_prefix, video_name,
suppress_output=self.quiet_mode or self.split_quiet)
elif ffmpeg_available:
if self.split_mkvmerge:
logging.warning('mkvmerge not found, falling back to normal splitting'
' mode (split-video).')
logging.info(
'Splitting input video%s using ffmpeg, output path template:\n %s',
's' if len(video_paths) > 1 else '', output_file_prefix)
split_video_ffmpeg(video_paths, scene_list, output_file_prefix,
video_name, arg_override=self.split_args,
hide_progress=self.quiet_mode,
Expand All @@ -446,8 +441,8 @@ def process_input(self):
error_str = '\n'.join(error_strs)
logging.debug(error_str)
raise click.BadParameter(error_str, param_hint='split-video')

logging.info('Video splitting completed, individual scenes written to disk.')
if scene_list:
logging.info('Video splitting completed, individual scenes written to disk.')



Expand Down
12 changes: 10 additions & 2 deletions scenedetect/video_splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,12 @@ def split_video_mkvmerge(input_video_paths, scene_list, output_file_prefix,
""" Calls the mkvmerge command on the input video(s), splitting it at the
passed timecodes, where each scene is written in sequence from 001. """

if not input_video_paths:
if not input_video_paths or not scene_list:
return

logging.info('Splitting input video%s using mkvmerge, output path template:\n %s',
's' if len(input_video_paths) > 1 else '', output_file_prefix)

ret_val = None
# mkvmerge automatically appends '-$SCENE_NUMBER'.
output_file_name = output_file_prefix.replace('-${SCENE_NUMBER}', '')
Expand Down Expand Up @@ -177,9 +181,13 @@ def split_video_ffmpeg(input_video_paths, scene_list, output_file_template, vide
""" Calls the ffmpeg command on the input video(s), generating a new video for
each scene based on the start/end timecodes. """

if not input_video_paths:
if not input_video_paths or not scene_list:
return

logging.info(
'Splitting input video%s using ffmpeg, output path template:\n %s',
's' if len(input_video_paths) > 1 else '', output_file_template)

if len(input_video_paths) > 1:
# TODO: Add support for splitting multiple/appended input videos.
# https://trac.ffmpeg.org/wiki/Concatenate#samecodec
Expand Down

0 comments on commit d70354b

Please sign in to comment.