Hi!
I want to create a addon which makes it easier to edit stripes from the sequencer with the compositor.
This is what I want to do:
Add a button in the Sequencer “Edit strip(s) in Compositor”, when pressed call the operator.
For each selected strip
if strip is a movie clip
Create new scene with same name as strip
Edit the scene endFrame to match strip length
Create a composite with the moviestrip file as input
Go back to original scene and add/position the newly created scene ontop of the moviestrip.
Script without GUI (select a moviestrip in the sequencer and run script)
import bpy
# Get selected strips
sel_strips = bpy.context.selected_sequences
# Get current scene
cur_scene = bpy.context.scene
# Loop selected strips
for strip in sel_strips:
# Check if strip is a movie
if (strip.type == 'MOVIE'):
# Create a new scene
new_scene = bpy.ops.scene.new(type='EMPTY')
# Name it after the moviestrip
bpy.context.scene.name = strip.name
# Change scene EndFrame to match strip
bpy.context.scene.frame_end = strip.frame_final_end
# Setup nodes
bpy.context.scene.use_nodes = True
tree = bpy.context.scene.node_tree
# Clear default nodes
for n in tree.nodes:
tree.nodes.remove(n)
# Create input node
rl = tree.nodes.new('IMAGE')
rl.location = 0,0
# Add strip path (NOT WORKING)
rl.layer = strip.filepath
# create output node
comp = tree.nodes.new('COMPOSITE')
comp.location = 400,0
# Link nodes
links = tree.links
link = links.new(rl.outputs[0],comp.inputs[0])
# Change current scene to original (NOT WORKING)
bpy.context.screen.scene = cur_scene
bpy.context.screen.scene.update()
# Add newly created scene
bpy.ops.sequencer.scene_strip_add(frame_start=strip.frame_start, channel=strip.channel + 1, replace_sel=False, scene=strip.name)
# Edit the strip length to match original strip
bpy.context.sequences[0].frame_final_end = strip.frame_final_end
This is what I have:
import bpy
class StripCompositorPanel(bpy.types.Panel):
bl_label = "Edit strip with Compositor"
bl_space_type = "SEQUENCE_EDITOR"
bl_region_type = "UI"
def draw(self, context):
layout = self.layout
row = layout.row()
row.operator( "bpt.stripcompositor_op" )
class StripCompositor(bpy.types.Operator):
bl_idname = "bpt.stripcompositor_op"
bl_label = "Edit strip(s) with Compositor"
def execute(self, context):
# Get selected strips
sel_strips = bpy.context.selected_sequences
# Get current scene
cur_scene = bpy.context.scene
# Loop selected strips
for strip in sel_strips:
# Check if strip is a movie
if (strip.type == 'MOVIE'):
# Create a new scene
new_scene = bpy.ops.scene.new(type='EMPTY')
# Name it after the moviestrip
bpy.context.scene.name = strip.name
# Change scene EndFrame to match strip
bpy.context.scene.frame_end = strip.frame_final_end
# Setup nodes
bpy.context.scene.use_nodes = True
tree = bpy.context.scene.node_tree
# Clear default nodes
for n in tree.nodes:
tree.nodes.remove(n)
# Create input node
rl = tree.nodes.new('IMAGE')
rl.location = 0,0
# Add strip path (NOT WORKING)
rl.layer = strip.filepath
# Create output node
comp = tree.nodes.new('COMPOSITE')
comp.location = 400,0
# Link nodes
links = tree.links
link = links.new(rl.outputs[0],comp.inputs[0])
# Change current scene to original (NOT WORKING)
bpy.context.screen.scene = cur_scene
bpy.context.screen.scene.update()
# Add newly created scene
bpy.ops.sequencer.scene_strip_add(frame_start=strip.frame_start, channel=strip.channel + 1, replace_sel=False, scene=strip.name)
# Edit the strip length to match original strip
bpy.context.sequences[0].frame_final_end = strip.frame_final_end
return {'FINISHED'}
def register():
bpy.utils.register_class( StripCompositor )
bpy.utils.register_class( StripCompositorPanel )
def unregister():
bpy.utils.register_class( StripCompositor )
bpy.utils.register_class( StripCompositorPanel )
if __name__ == '__main__':
register()
This is my problems:
GUI: Button is not visible in the UI.
Sequencer: Scenes gets added in the newly created scene(itself) instead of the original, containing the moviestrip.
Compositor: I don’t know how to link the input node with the moviecllip
Any help on this would be appreciated!