one movie by splitter

pull/6/head
florentin.luce 2024-05-24 11:12:13 +02:00
parent a30e16606b
commit b1bde01b57
2 changed files with 22 additions and 19 deletions

View File

@ -7,16 +7,16 @@ from vse_toolbox import file_utils
class AutoSplitter(object):
def __init__(self, paths, fps=None):
def __init__(self, path, fps=None):
self.paths = paths
self.path = path
self.fps = fps
self.log_path = AUTO_SPLITTER_LOG
def launch_analysis(self, threshold=0.6):
ffmpeg_cmd = f"ffmpeg -i {str(self.paths[0])} -filter:v \"select='gt(scene,{threshold})',showinfo\" -f null - 2> {str(self.log_path)}"
ffmpeg_cmd = f"ffmpeg -i {str(self.path)} -filter:v \"select='gt(scene,{threshold})',showinfo\" -f null - 2> {str(self.log_path)}"
print(ffmpeg_cmd)
subprocess.call(ffmpeg_cmd, shell=True)

View File

@ -200,30 +200,33 @@ class VSETB_OT_auto_split(Operator):
def execute(self, context):
scn = context.scene
first_frame = int(scn.frame_start)
strips = get_strips('Movie')
if self.selected_only:
strips = context.selected_sequences
sources = list(set([bpy.path.abspath(strip.filepath) for strip in strips if strip.type == 'MOVIE']))
for strip in strips:
splitter = AutoSplitter(sources)
splitter.launch_analysis(self.threshold)
if strip.type != 'MOVIE':
continue
split_frames = [0]
split_frames += splitter.get_split_times(as_frame=True)
splitter = AutoSplitter(bpy.path.abspath(strip.filepath))
splitter.launch_analysis(self.threshold)
for i, frame in enumerate(split_frames):
strip = scn.sequence_editor.sequences.new_effect(
f'tmp_shot_{str(i).zfill(3)}',
'COLOR',
get_channel_index('Shots'),
frame_start=frame + first_frame,
frame_end=split_frames[i+1] + first_frame if i < len(split_frames) else strips[0].frame_final_end
)
strip.blend_alpha = 0
strip.color = (0.5, 0.5, 0.5)
split_frames = [0]
split_frames += splitter.get_split_times(as_frame=True)
for i, frame in enumerate(split_frames):
shot_strip = scn.sequence_editor.sequences.new_effect(
f'tmp_shot_{str(i).zfill(3)}',
'COLOR',
get_channel_index('Shots'),
frame_start=frame + strip.frame_final_start,
frame_end=split_frames[i+1] + strip.frame_final_start if i+1 < len(split_frames) else strip.frame_final_end
)
shot_strip.blend_alpha = 0
shot_strip.color = (0.5, 0.5, 0.5)
return {'FINISHED'}