one movie by splitter
parent
a30e16606b
commit
b1bde01b57
|
@ -7,16 +7,16 @@ from vse_toolbox import file_utils
|
||||||
|
|
||||||
class AutoSplitter(object):
|
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.fps = fps
|
||||||
|
|
||||||
self.log_path = AUTO_SPLITTER_LOG
|
self.log_path = AUTO_SPLITTER_LOG
|
||||||
|
|
||||||
def launch_analysis(self, threshold=0.6):
|
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)
|
print(ffmpeg_cmd)
|
||||||
|
|
||||||
subprocess.call(ffmpeg_cmd, shell=True)
|
subprocess.call(ffmpeg_cmd, shell=True)
|
||||||
|
|
|
@ -200,30 +200,33 @@ class VSETB_OT_auto_split(Operator):
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
scn = context.scene
|
scn = context.scene
|
||||||
first_frame = int(scn.frame_start)
|
|
||||||
|
|
||||||
strips = get_strips('Movie')
|
strips = get_strips('Movie')
|
||||||
if self.selected_only:
|
if self.selected_only:
|
||||||
strips = context.selected_sequences
|
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)
|
if strip.type != 'MOVIE':
|
||||||
splitter.launch_analysis(self.threshold)
|
continue
|
||||||
|
|
||||||
split_frames = [0]
|
splitter = AutoSplitter(bpy.path.abspath(strip.filepath))
|
||||||
split_frames += splitter.get_split_times(as_frame=True)
|
splitter.launch_analysis(self.threshold)
|
||||||
|
|
||||||
for i, frame in enumerate(split_frames):
|
split_frames = [0]
|
||||||
strip = scn.sequence_editor.sequences.new_effect(
|
split_frames += splitter.get_split_times(as_frame=True)
|
||||||
f'tmp_shot_{str(i).zfill(3)}',
|
|
||||||
'COLOR',
|
for i, frame in enumerate(split_frames):
|
||||||
get_channel_index('Shots'),
|
|
||||||
frame_start=frame + first_frame,
|
shot_strip = scn.sequence_editor.sequences.new_effect(
|
||||||
frame_end=split_frames[i+1] + first_frame if i < len(split_frames) else strips[0].frame_final_end
|
f'tmp_shot_{str(i).zfill(3)}',
|
||||||
)
|
'COLOR',
|
||||||
strip.blend_alpha = 0
|
get_channel_index('Shots'),
|
||||||
strip.color = (0.5, 0.5, 0.5)
|
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'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue