Page 1 of 17 12311 ... LastLast
Results 1 to 20 of 333
  1. #1
    Member
    Join Date
    Apr 2007
    Location
    Gothenburg, Sweden
    Posts
    138

    Edit strip with compositor

    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)
    Code:
    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:
    Code:
    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!
    Last edited by peddie; 13-Jun-11 at 08:17.



  2. #2
    Member 3pointEdit's Avatar
    Join Date
    Sep 2005
    Location
    Brisbane, Australia
    Posts
    8,596
    Reminds me a little of Carlos's Hipostatiator script but that makes other scenes to use multiple VSEs.
    http://www.surreal.asturnazari.es/co...-hipostasiator

    There maybe some cross over between the two ideas, and Strip-to nodes-to strip is an workflow I have wanted to see for ages. Perhaps you could even bundle the original strip and it's node child strip, together in a Meta strip. So it doesn't loose sync. Although that would make de-activating Nodes (for speed) difficult.

    Good luck and I hope this script (if it works out ok) is accepted into trunk distribution, as so many languish as the API matures Like Carlos's Jump-to-cut script. It is great but won't function unless maintained.
    Cheers, David ___________"awesome in space and other places".
    ________Follow me on twitter @3pointedit
    _____________ Check the Youtube Channel for tutorials. Or my Sketchbook



  3. #3
    Member
    Join Date
    Apr 2007
    Location
    Gothenburg, Sweden
    Posts
    138
    Thank you David!

    I also think this workflow could be extremely powerful, but unfortunately I'm stuck at my 3 points above and I really need some help with those to continue my proposal.



  4. #4
    Member
    Join Date
    Apr 2007
    Location
    Gothenburg, Sweden
    Posts
    138
    I can't figure it out, it's like this:
    bpy.context.screen.scene = cur_scene
    bpy.context.screen.scene.update()
    gets executed after this:
    bpy.ops.sequencer.scene_strip_add(frame_start=stri p.frame_start, channel=strip.channel + 1, replace_sel=False, scene=strip.name)
    Even though it comes earlier in the script??



  5. #5
    Member
    Join Date
    Jan 2007
    Location
    Planet Earth
    Posts
    1,465
    peddie go to freenode.irc channel #blendercoders , use webfreenode irc or other type of clients. On that channel you can ask same question here about your script and someone of the developers can help you.



  6. #6
    Member
    Join Date
    Apr 2007
    Location
    Gothenburg, Sweden
    Posts
    138
    Originally Posted by Numarul7 View Post
    peddie go to freenode.irc channel #blendercoders , use webfreenode irc or other type of clients. On that channel you can ask same question here about your script and someone of the developers can help you.
    Thanks Numarul7, although isn't this the correct forum for python support? I logged in to #blendercoders but I got no response from anyone (maybe it's the time difference).
    Last edited by peddie; 14-Jun-11 at 01:26.



  7. #7
    Member
    Join Date
    Apr 2007
    Location
    Gothenburg, Sweden
    Posts
    138
    Bumping this since I think it's an important feature and I don't know how to solve the issues above.



  8. #8
    Member 3pointEdit's Avatar
    Join Date
    Sep 2005
    Location
    Brisbane, Australia
    Posts
    8,596
    You could try asking about the GUI issue separately.

    To access the movie clip (from VSE) I don't think it appears as an asset to Nodes. When I add clips to Nodes I always have to search for them again. Unless the movie has been added as a texture, then it is available throughout Blender.
    Last edited by 3pointEdit; 16-Jun-11 at 03:34. Reason: edits
    Cheers, David ___________"awesome in space and other places".
    ________Follow me on twitter @3pointedit
    _____________ Check the Youtube Channel for tutorials. Or my Sketchbook



  9. #9
    Member
    Join Date
    Feb 2009
    Location
    UK
    Posts
    122
    I don't know if this will be any more successful but the freenode irc channel for python help is #blenderpython.



  10. #10
    Member
    Join Date
    Nov 2009
    Posts
    165
    Hi,

    This looks good, where is the button supposed to appear in the VSE UI?

    Thanks
    Tom
    Last edited by TMW; 20-Jun-11 at 11:02. Reason: (Email subscription)



  11. #11
    Member
    Join Date
    Nov 2009
    Posts
    165
    Hi,

    I don't know if this helps:

    Code:
    import bpy
     
    class CompPanel(bpy.types.Panel):
        bl_label = "Strip Comp"
        bl_space_type = "PROPERTIES"
        bl_region_type = "WINDOW"
        bl_context = "object"
     
        def draw(self, context):
            scn = bpy.context.scene
            layout = self.layout
            row = layout.row()
            col = row.column()
     
     
            col.operator( "bpt.sample_op" )
     
     
    class CompOperator(bpy.types.Operator):
     
        bl_idname = "bpt.sample_op"
        bl_label = "Strip Comp"
     
        def invoke(self, context, event ):
     
            # 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
     
                    self.report( "INFO", "RUN" )
     
                    return {'FINISHED'}
     
     
    def register():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    def unregister():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    if __name__ == "__main__":
        register()
    It has the button in the objects tab (thats all I could get to work) and it adds the node, and says it can't find the clip (in the new scene).

    Thanks
    Tom
    Last edited by TMW; 20-Jun-11 at 16:01.



  12. #12
    Member
    Join Date
    Nov 2009
    Posts
    165
    Sorry, got it in the Render Panel now, I don't now how to do the VSE.

    Code:
    import bpy
     
    class CompPanel(bpy.types.Panel):
        bl_label = "Strip Comp"
        bl_space_type = "PROPERTIES"
        bl_region_type = "WINDOW"
        bl_context = "render"
     
        def draw(self, context):
            scn = bpy.context.scene
            layout = self.layout
            row = layout.row()
            col = row.column()
     
     
            col.operator( "bpt.sample_op" )
     
     
    class CompOperator(bpy.types.Operator):
     
        bl_idname = "bpt.sample_op"
        bl_label = "Strip Comp"
     
        def invoke(self, context, event ):
            
            # 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
                    
                    self.report( "INFO", "RUN" )
        
                    return {'FINISHED'}
     
     
    def register():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    def unregister():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    if __name__ == "__main__":
        register()
    Thanks
    Tom



  13. #13
    Member 3pointEdit's Avatar
    Join Date
    Sep 2005
    Location
    Brisbane, Australia
    Posts
    8,596
    I think that the only place to put buttons is in a VSE Strip properties panel. Check out the new Jump-to-cut.p script at:
    http://www.surreal.asturnazari.es/node/197
    and thread at:
    http://blenderartists.org/forum/show...44#post1885244
    It places buttons on a Strip's properties.
    Cheers, David ___________"awesome in space and other places".
    ________Follow me on twitter @3pointedit
    _____________ Check the Youtube Channel for tutorials. Or my Sketchbook



  14. #14
    Member
    Join Date
    Apr 2007
    Location
    Gothenburg, Sweden
    Posts
    138
    Hi and thanks for the replies.

    I have updated the GUI and code which now adds a working button in the properties panel of a strip (thanks to TMW):
    Code:
    import bpy
     
    class CompPanel(bpy.types.Panel):
        bl_space_type = "SEQUENCE_EDITOR"
        bl_region_type = "UI"
        bl_label = "Edit strip with Compositor"
     
        def draw(self, context):
            scn = bpy.context.scene
            layout = self.layout
            row = layout.row()
            col = row.column()
     
     
            col.operator( "bpt.sample_op" )
     
     
    class CompOperator(bpy.types.Operator):
     
        bl_idname = "bpt.sample_op"
        bl_label = "Edit strip with Compositor"
     
        def invoke(self, context, event ):
            
                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
                    
                    self.report( "INFO", "DONE!" )
                return {'FINISHED'}
     
     
    def register():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    def unregister():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    if __name__ == "__main__":
        register()
    Things that still doesn't work:
    1. Newly created scene-strips gets added to it's own VSE (instead of the original scene).
    2. Input node still doesn't link to the video.



  15. #15
    Member
    Join Date
    Nov 2009
    Posts
    165
    Hi,

    This seems to sort of solve the file path issue, it knows the path, but says "not found in ()" and I don't know what that means.

    Code:
    import bpy
     
    class CompPanel(bpy.types.Panel):
        bl_space_type = "SEQUENCE_EDITOR"
        bl_region_type = "UI"
        bl_label = "Edit strip with Compositor"
     
        def draw(self, context):
            scn = bpy.context.scene
            layout = self.layout
            row = layout.row()
            col = row.column()
     
     
            col.operator( "bpt.sample_op" )
     
     
    class CompOperator(bpy.types.Operator):
     
        bl_idname = "bpt.sample_op"
        bl_label = "Edit strip with Compositor"
     
        def invoke(self, context, event ):
            
                import bpy
                # Get selected strips
                sel_strips = bpy.context.selected_sequences
                
                # Get current scene
                cur_scene = bpy.context.scene
                
                for strip in sel_strips:
                    #filepath
                  a = strip.filepath  
                  b = bpy.path.resolve_ncase(a)
                
                # 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
                    print(dir(strip.filepath.find))
                    # Add strip path (NOT WORKING)
                    rl.layer = b
                
                    # 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
                    
                    self.report( "INFO", "DONE!" )
                return {'FINISHED'}
     
     
    def register():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    def unregister():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    if __name__ == "__main__":
        register()
    Thanks
    Tom



  16. #16
    Member
    Join Date
    Apr 2007
    Location
    Gothenburg, Sweden
    Posts
    138
    Nice find Tom, unfortunetly I don't know what that message means either.

    Here is the latest code:
    Code:
    import bpy
     
    class CompPanel(bpy.types.Panel):
        bl_space_type = "SEQUENCE_EDITOR"
        bl_region_type = "UI"
        bl_label = "Edit strip with Compositor"
     
        def draw(self, context):
            scn = bpy.context.scene
            layout = self.layout
            row = layout.row()
            col = row.column()
     
     
            col.operator( "bpt.sample_op" )
     
     
    class CompOperator(bpy.types.Operator):
     
        bl_idname = "bpt.sample_op"
        bl_label = "Edit strip with Compositor"
     
        def invoke(self, context, event ):
            
                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 
                    FilePath = bpy.path.resolve_ncase(strip.filepath)
                    # Add strip path (NOT WORKING)
                    #rl.layer = 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
                    bpy.context.sequences[0].frame_final_start = strip.frame_final_start
                    
                    self.report( "INFO", "DONE!" )
                return {'FINISHED'}
     
     
    def register():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    def unregister():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    if __name__ == "__main__":
        register()
    Minor fixes for the strip length but the problems from earlier remains unsolved.



  17. #17
    Member
    Join Date
    Nov 2009
    Posts
    165
    I also found this, replace the 'Scene' with whatever scene you want to change to:

    Code:
    bpy.context.screen.scene = bpy.data.scenes['Scene']
    it works in the Python console, but not in the script editor for some reason (could be I'm missing something).

    Thanks
    Tom



  18. #18
    Member
    Join Date
    Nov 2009
    Posts
    165
    Hi,

    This sort of works, it adds the new scene without making it the active scene, so the Scene strip is added to the correct sequence editor. However all nodes have to be added by hand.

    Code:
    import bpy
     
    class CompPanel(bpy.types.Panel):
        bl_space_type = "SEQUENCE_EDITOR"
        bl_region_type = "UI"
        bl_label = "Edit strip with Compositor"
     
        def draw(self, context):
            scn = bpy.context.scene
            layout = self.layout
            row = layout.row()
            col = row.column()
     
     
            col.operator( "bpt.sample_op" )
     
     
    class CompOperator(bpy.types.Operator):
     
        bl_idname = "bpt.sample_op"
        bl_label = "Edit strip with Compositor"
     
        def invoke(self, context, event ):
            
                import bpy
                # Get selected strips
                sel_strips = bpy.context.selected_sequences
                
                # Get current scene
                cur_scene = bpy.data.scenes["Scene"]
                # Loop selected strips                         
                for strip in sel_strips:
                
                  # Check if strip is a movie
                  if (strip.type == 'MOVIE'):
                    # Create a new scene
                    #This makes the new scene, but doesn't set it as active so the Scene strip is added to the correxct scen. However you have to add the nodes yourself.
                    new_scene = bpy.data.scenes.new(strip.name)
                    
                    # Name it after the moviestrip
                    #bpy.context.scene.name = strip.name
                    
                    
                    # Change scene EndFrame to match strip             
                    #bpy.context.scene[strip.name].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 
                    FilePath = bpy.path.resolve_ncase(strip.filepath)
                    # Add strip path (NOT WORKING)
                    #rl.layer = 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)                          
                    
                    data_context = {"blend_data": bpy.context.blend_data, "Scene": new_scene}
                    bpy.context.screen.scene.update()
                    print(bpy.data.screens['Video Editing'].scene) 
                    
                    # 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[1].frame_final_end = strip.frame_final_end
                    bpy.context.sequences[1].frame_final_start = strip.frame_final_start
                    
                    self.report( "INFO", "DONE!" )
                return {'FINISHED'}
     
     
    def register():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    def unregister():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    if __name__ == "__main__":
        register()
    Thanks
    Tom



  19. #19
    Member
    Join Date
    Apr 2007
    Location
    Gothenburg, Sweden
    Posts
    138

    Sweet!

    Thanks Tom!

    I solved the nodes part and also figured out how to link the input node with the original file. Everything seems to be working as it should over here:
    Code:
    import bpy
     
    class CompPanel(bpy.types.Panel):
        bl_space_type = "SEQUENCE_EDITOR"
        bl_region_type = "UI"
        bl_label = "Edit strip with Compositor"
     
        def draw(self, context):
            scn = bpy.context.scene
            layout = self.layout
            row = layout.row()
            col = row.column()
     
     
            col.operator( "bpt.sample_op" )
     
     
    class CompOperator(bpy.types.Operator):
     
        bl_idname = "bpt.sample_op"
        bl_label = "Edit strip with Compositor"
     
        def invoke(self, context, event ):
            
                import bpy
                
                # Get selected strips
                sel_strips = bpy.context.selected_sequences
                
                # Get current scene
                cur_scene = bpy.data.scenes["Scene"]
                
                # Loop selected strips                         
                for strip in sel_strips:
                
                  # Check if strip is a movie
                  if (strip.type == 'MOVIE'):
    
                    #Creates new scene but doesn't set it as active.
                    new_scene = bpy.data.scenes.new(strip.name)
                    
                    # Change scene EndFrame to match strip length            
                    new_scene.frame_end = strip.frame_final_duration
                    
                    # Setup nodes
                    new_scene.use_nodes = True
                    tree = new_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 
                    
                    #Get source of strip
                    StripPath = bpy.path.resolve_ncase(strip.filepath)
                    StripSource = bpy.data.images.load(StripPath)
                    
                    # Add strip path
                    rl.image = StripSource
                    
                    # Other settings
                    rl.use_cyclic = True
                    rl.use_auto_refresh = True
                    rl.frame_duration = strip.frame_final_duration
                    rl.frame_offset = strip.frame_offset_start
    
                    # 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                                    
                    data_context = {"blend_data": bpy.context.blend_data, "Scene": new_scene}
                    bpy.context.screen.scene.update()
                    
                    # Add newly created scene                                           
                    bpy.ops.sequencer.scene_strip_add(frame_start=strip.frame_final_start, channel=strip.channel + 1, replace_sel=False, scene=new_scene.name)                                
                    # Edit the strip length to match original strip                                                  
                    bpy.context.sequences[0].frame_final_end = strip.frame_final_end
                    
                    self.report( "INFO", "DONE!" )
                return {'FINISHED'}
     
     
    def register():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    def unregister():
        bpy.utils.register_class( CompPanel )
        bpy.utils.register_class( CompOperator )
     
     
    if __name__ == "__main__":
        register()
    Now I will test it out and see what could be improved.. I'm not completely happy with how the scene-strips just lands one channel above the original, but maybe that's the way to go!

    Thanks for your hard work and support!
    Last edited by peddie; 25-Jun-11 at 14:40.



  20. #20
    Member
    Join Date
    Nov 2009
    Posts
    165
    Thats great. one problem is there isn't always a camera in your new scene (if you had already deleted it from your origional), this means the new scene cannot render. Also the new scene needs to have the same render settings as the origional. I'll see what I can do.

    Thanks
    Tom



Page 1 of 17 12311 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •