Meta Strip
This commit is contained in:
parent
0c9b646690
commit
2803d6ec6d
|
|
@ -88,13 +88,16 @@ class SEQUENCER_OT_apply_mask_blur(Operator):
|
||||||
|
|
||||||
def _apply_with_mask_modifier(self, context, video_strip: "bpy.types.Strip", mask_strip: "bpy.types.Strip"):
|
def _apply_with_mask_modifier(self, context, video_strip: "bpy.types.Strip", mask_strip: "bpy.types.Strip"):
|
||||||
"""
|
"""
|
||||||
Apply blur using Mask Modifier.
|
Apply blur using Mask Modifier, grouped in a Meta Strip.
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
1. Duplicate the video strip
|
1. Duplicate the video strip
|
||||||
2. Create Gaussian Blur effect on the duplicate
|
2. Create Gaussian Blur effect on the duplicate
|
||||||
3. Add Mask modifier to the blur effect (references mask strip)
|
3. Add Mask modifier to the blur effect (references mask strip)
|
||||||
4. Composite with Alpha Over effect
|
4. Group all into a Meta Strip
|
||||||
|
|
||||||
|
The blur effect with mask will automatically composite over the original
|
||||||
|
video due to VSE's channel layering system.
|
||||||
"""
|
"""
|
||||||
seq_editor = context.scene.sequence_editor
|
seq_editor = context.scene.sequence_editor
|
||||||
|
|
||||||
|
|
@ -108,10 +111,6 @@ class SEQUENCER_OT_apply_mask_blur(Operator):
|
||||||
while blur_channel in used_channels:
|
while blur_channel in used_channels:
|
||||||
blur_channel += 1
|
blur_channel += 1
|
||||||
|
|
||||||
composite_channel = blur_channel + 1
|
|
||||||
while composite_channel in used_channels:
|
|
||||||
composite_channel += 1
|
|
||||||
|
|
||||||
# Step 1: Duplicate the video strip
|
# Step 1: Duplicate the video strip
|
||||||
if video_strip.type == 'MOVIE':
|
if video_strip.type == 'MOVIE':
|
||||||
video_copy = seq_editor.strips.new_movie(
|
video_copy = seq_editor.strips.new_movie(
|
||||||
|
|
@ -168,22 +167,37 @@ class SEQUENCER_OT_apply_mask_blur(Operator):
|
||||||
mask_mod.input_mask_type = 'STRIP'
|
mask_mod.input_mask_type = 'STRIP'
|
||||||
mask_mod.input_mask_id = mask_strip
|
mask_mod.input_mask_id = mask_strip
|
||||||
|
|
||||||
# Step 4: Composite with Alpha Over effect
|
# Hide the mask strip (but keep it active for the modifier)
|
||||||
alpha_over = seq_editor.strips.new_effect(
|
|
||||||
name=f"{video_strip.name}_composite",
|
|
||||||
type='ALPHA_OVER',
|
|
||||||
channel=composite_channel,
|
|
||||||
frame_start=video_strip.frame_final_start,
|
|
||||||
length=strip_length,
|
|
||||||
input1=video_strip, # Base (original)
|
|
||||||
input2=blur_effect, # Blurred with mask
|
|
||||||
)
|
|
||||||
|
|
||||||
# Hide intermediate strips (but keep them active)
|
|
||||||
video_copy.mute = True
|
|
||||||
mask_strip.mute = True
|
mask_strip.mute = True
|
||||||
|
|
||||||
self.report({'INFO'}, f"Applied blur with Mask Modifier (composite on channel {composite_channel})")
|
# Step 4: Create Meta Strip to group everything
|
||||||
|
# Deselect all first
|
||||||
|
for strip in seq_editor.strips:
|
||||||
|
strip.select = False
|
||||||
|
|
||||||
|
# Select the strips to group
|
||||||
|
video_copy.select = True
|
||||||
|
blur_effect.select = True
|
||||||
|
mask_strip.select = True
|
||||||
|
|
||||||
|
# Set active strip for context
|
||||||
|
seq_editor.active_strip = blur_effect
|
||||||
|
|
||||||
|
# Create meta strip using operator
|
||||||
|
bpy.ops.sequencer.meta_make()
|
||||||
|
|
||||||
|
# Find the newly created meta strip (it will be selected)
|
||||||
|
meta_strip = None
|
||||||
|
for strip in seq_editor.strips:
|
||||||
|
if strip.select and strip.type == 'META':
|
||||||
|
meta_strip = strip
|
||||||
|
break
|
||||||
|
|
||||||
|
if meta_strip:
|
||||||
|
meta_strip.name = f"{video_strip.name}_blurred_meta"
|
||||||
|
self.report({'INFO'}, f"Applied blur with Mask Modifier (grouped in Meta Strip)")
|
||||||
|
else:
|
||||||
|
self.report({'INFO'}, f"Applied blur with Mask Modifier (blur on channel {blur_channel})")
|
||||||
|
|
||||||
def _apply_with_meta_strip(self, context, video_strip: "bpy.types.Strip", mask_strip: "bpy.types.Strip"):
|
def _apply_with_meta_strip(self, context, video_strip: "bpy.types.Strip", mask_strip: "bpy.types.Strip"):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user