Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.split_name_format,
self.split_directory if self.split_directory is not None
else self.output_directory)
mkvmerge_available = is_mkvmerge_available()
ffmpeg_available = is_ffmpeg_available()
if mkvmerge_available and (self.split_mkvmerge or not ffmpeg_available):
if not self.split_mkvmerge:
logging.warning(
'ffmpeg not found, falling back to fast copy mode (split-video -c/--copy).')
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).')
split_video_ffmpeg(video_paths, scene_list, output_file_prefix,
video_name, arg_override=self.split_args,
hide_progress=self.quiet_mode,
suppress_output=self.quiet_mode or self.split_quiet)
else:
if not (mkvmerge_available or ffmpeg_available):
error_strs = ["ffmpeg/mkvmerge is required for split-video [-c/--copy]."]
else:
error_strs = [
"{EXTERN_TOOL} is required for split-video{EXTRA_ARGS}.".format(
EXTERN_TOOL='mkvmerge' if self.split_mkvmerge else 'ffmpeg',
EXTRA_ARGS=' -c/--copy' if self.split_mkvmerge else '')]
error_strs += ["Install one of the above tools to enable the split-video command."]
error_str = '\n'.join(error_strs)
logging.debug(error_str)
raise click.BadParameter(error_str, param_hint='split-video')
if scene_list:
print('%s scenes obtained' % len(scene_list))
if len(scene_list)>0:
# STATISTICS : Store scenes length
with open(FILE_SCENE_LENGH,'a') as myfile:
for i, scene in enumerate(scene_list):
myfile.write('%s, %d, %f\n' % (os.path.splitext(os.path.basename(video_path))[0], scene[1].get_frames()-scene[0].get_frames(), (scene[1]-scene[0]).get_seconds()))
# STATISTICS : Store number of scenes
with open(FILE_SCENE_NUMBER,'a') as myfile:
myfile.write('%s,%d\n'%(os.path.splitext(os.path.basename(video_path))[0],len(scene_list)))
# Split the video
print('Splitting the video. Put scenes in %s/%s'%(folder,VIDEO_SPLIT_TEMPLATE))
os.mkdir(folder)
video_splitter.split_video_ffmpeg([video_path], scene_list, folder+"/"+VIDEO_SPLIT_TEMPLATE+".mp4", os.path.basename(folder),suppress_output=True)
print("-- Finished video splitting in {:.2f}s --".format(time.time() - start_time))
else:
print('Ffmpeg is not installed on your computer. Please install it before running this code')
finally:
video_manager.release()
return scene_list
self.split_name_format,
self.split_directory if self.split_directory is not None
else self.output_directory)
mkvmerge_available = is_mkvmerge_available()
ffmpeg_available = is_ffmpeg_available()
if mkvmerge_available and (self.split_mkvmerge or not ffmpeg_available):
if not self.split_mkvmerge:
logging.warning(
'ffmpeg not found, falling back to fast copy mode (split-video -c/--copy).')
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).')
split_video_ffmpeg(video_paths, scene_list, output_file_prefix,
video_name, arg_override=self.split_args,
hide_progress=self.quiet_mode,
suppress_output=self.quiet_mode or self.split_quiet)
else:
if not (mkvmerge_available or ffmpeg_available):
error_strs = ["ffmpeg/mkvmerge is required for split-video [-c/--copy]."]
else:
error_strs = [
"{EXTERN_TOOL} is required for split-video{EXTRA_ARGS}.".format(
EXTERN_TOOL='mkvmerge' if self.split_mkvmerge else 'ffmpeg',
EXTRA_ARGS=' -c/--copy' if self.split_mkvmerge else '')]
error_strs += ["Install one of the above tools to enable the split-video command."]
error_str = '\n'.join(error_strs)
logging.debug(error_str)
raise click.BadParameter(error_str, param_hint='split-video')
if scene_list: