Split auto (UI + Core) - 1st version
This commit is contained in:
+58
-1
@@ -2,12 +2,13 @@ from os.path import expandvars, abspath
|
||||
from pathlib import Path
|
||||
import bpy
|
||||
from bpy.types import Operator
|
||||
from bpy.props import (BoolProperty, StringProperty, EnumProperty)
|
||||
from bpy.props import (BoolProperty, StringProperty, EnumProperty, FloatProperty)
|
||||
|
||||
from vse_toolbox.sequencer_utils import (get_strips, rename_strips, set_channels,
|
||||
get_channel_index, new_text_strip, get_strip_at, get_channel_name)
|
||||
|
||||
from vse_toolbox.bl_utils import get_scene_settings, get_strip_settings
|
||||
from vse_toolbox.auto_splitter import AutoSplitter
|
||||
from vse_toolbox.constants import REVIEW_TEMPLATE_BLEND
|
||||
from shutil import copy2
|
||||
|
||||
@@ -172,6 +173,61 @@ class VSETB_OT_set_sequencer(Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class VSETB_OT_auto_split(Operator):
|
||||
"""Launch subprocess with ffmpeg and python to find and create each
|
||||
shots strips from video source"""
|
||||
|
||||
bl_idname = "vse_toolbox.auto_split"
|
||||
bl_label = "Auto Split"
|
||||
bl_description = "Generate shots strips"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
threshold: FloatProperty(name="Threshold", default=0.6, min=0, max=1)
|
||||
selected_only: BoolProperty(name="Selected Only", default=True)
|
||||
|
||||
def invoke(self, context, event):
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
col = layout.column()
|
||||
col.use_property_split = True
|
||||
col.use_property_decorate = False
|
||||
|
||||
col.prop(self, 'threshold')
|
||||
col.prop(self, 'selected_only')
|
||||
|
||||
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']))
|
||||
|
||||
splitter = AutoSplitter(sources)
|
||||
splitter.launch_analysis(self.threshold)
|
||||
|
||||
split_frames = [0]
|
||||
split_frames += splitter.get_split_times(as_frame=True)
|
||||
|
||||
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)
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class VSETB_OT_set_stamps(Operator):
|
||||
bl_idname = "vse_toolbox.set_stamps"
|
||||
bl_label = "Set Stamps"
|
||||
@@ -625,6 +681,7 @@ def unregister_keymaps():
|
||||
classes = (
|
||||
VSETB_OT_rename,
|
||||
VSETB_OT_set_sequencer,
|
||||
VSETB_OT_auto_split,
|
||||
VSETB_OT_set_stamps,
|
||||
VSETB_OT_show_waveform,
|
||||
VSETB_OT_previous_shot,
|
||||
|
||||
Reference in New Issue
Block a user