Scripting for the Video Sequence Editor

Is it even possible? I did a brief search on the API, and a more thorough Google search, and came up with nothing on Blender Python scripting for the Video Sequence Editor.

Did Blender never venture down that road?

I started writing an API for the sequencer, its in CVS but its not finished.
you can add and move strips, and deal with metastrips, but not split yet.

what are you interested in doing?

I just need to make a script that adds images from files and puts them together into one big animation. I always render to JPegs for safety’s sake and assemble them thereafter, thought I’d automate that a bit. If you know how to do so or where to learn it, I’d be mighty happy. If it includes audio strips and asking for a’mixdown’, I’d be doubly thrilled :slight_smile:

And I must admit to respect for your work. About half the script research I do, your name pops up :eek:

Hi, testing this I found a bug in the api, so youll need a build from this time hense :-/

Heres an example

import bpy

import os
img_path = '/someimage_path'
img_ext = '.jpg'

def main():
    sce =
    seq = sce.sequence
    if not seq:
        print 'This scene has no sequence data yet'
    print seq
    start = 50
    track = 2
    # Gather image names
    images = [i for i in os.listdir(img_path) if i.lower().endswith(img_ext)]
    print images
    # Images must all be in the one path
    # so the path is given as the argument
    seq_data = ( img_path, images )
    strip =, start, track)

Hi, I completely forgot to follow up on this… where can I find a build that allows sequencer scripting, and will such yummy goodness be in Blender 2.5?

Hi Ideasman,
This would be awesome! Can I make some suggestions?

  1. Adding/removing image/sound/video and meta strips (like beingt able to add a single file in, then adding a directory of files could be done by a script, though a function to add all files in a directory with a filter - *.wav, *.jpg etc would be cool)
  2. Able to move things around, both in time, and also the layers.
  3. Adding effects (difference, alpha over/alpha under etc) to strips
  4. getting the length of a strip (in frames?)
    coz then you could do this wonderful things:
    Make a script to automatically load in image directories (with foreground and background images), comp them together and spit out a video (or whatever, more frames even).
    I’m sure you could do other things, maybe render out frames, comp them, and use them in another animation/script, like a feedback loop…

Oh yeah, is anyone scripting the nodes (texture and comping) window?

I too would like access to the Video Sequence Editor information but I can’t figure out how (if it’s possible). I’m coding an exporter for a game engine I made and basically I just need to read audio info from the strips and write the info in an XML. That way I can put audio strips together with the cinematic in blender and have all of that exported at once.

I looked through the API and on the web everywhere. Can’t find how to do it.

hi, an exporter for audio strips would not be that hard… atm I dont have any time for this but I’ll write docs before the next release :wink:

the best you can do for now is read the source,

have a look at the PyGetSetDef for stip options.

Now that the thread came alive again, I was wondering if anything had happened since my OP on API’ing the sequencer, and/or if someone could point me to whatever commands exist (if any!) to python somehting for the sequencer…?

I have a similar desire to script the loading of some image files and turn them into an avi. I’ve implemented the following code using Blender 2.44, and I can load the images and create the avi automatically with no problem, however I need to repeat this process 256 more times. I’ve noticed there’s a remove function but it doesn’t seem to work as expected and I can’t find any documentation for it. Anyone know how I can remove the strip from the sequencer?

import Blender
from Blender import *
import os

img_path = ""
img_ext  = '.jpg'

def setPath(directory):
    global img_path
    img_path = directory
    print img_path

def renderAnimation():
    scn = Scene.GetCurrent()
    seq = scn.sequence
    #load images
    start = 1
    track = 2
    images = [i for i in os.listdir(img_path) if i.lower().endswith(img_ext)]
    seq_data = (img_path, images)
    strip =, start, track)
    #render settings
    context = scn.getRenderingContext()
    saveName = img_path + "\\" + (img_path.split("\\"))[-2] + ".avi"
    #render animation
    #clean up
def renderDir(dirName):

Blender.Window.FileSelector(renderDir, 'Select directory')

I would think that even if you cannot remove the individual images, you can program the script to shut down the scene altogether and create the new one from scratch?

On another note, is that script usable in the standard, official build of Blender, and do you have a link to the API for the video sequencer??

EDIT: Okay, I tried and tried, but Blender insists that “Scene.sequence” is a NoneType, and thus has no ‘New’ property. What am I doing wrong? :frowning:

Well, I tried it by first making a new scene and then creating the new strip but now I run into the same problem as you:

AttributeError: ‘NoneType’ object has no attribute ‘new’

But using print dir(seq) gives me:

[‘class’, ‘delattr’, ‘doc’, ‘getattribute’, ‘hash’, ‘init’, ‘new’, ‘reduce’, ‘reduce_ex’, ‘repr’, ‘setattr’, ‘str’]

and it recognizes the, but doesn’t like the arguments I pass into it.

When I create the new strip in the sequence of the default scene (‘Scene’) print dir(seq) gives:

[‘class’, ‘cmp’, ‘delattr’, ‘doc’, ‘getattribute’, ‘hash’, ‘init’, ‘iter’, ‘new’, ‘reduce’, ‘reduce_ex’, ‘repr’, ‘setattr’, ‘str’, ‘active’, ‘metastrip’, ‘new’, ‘next’, ‘remove’]

I think I may have had to manually load images into the sequencer before it worked the first time, not sure b/c that was when I had left in the:

if not seq:
     print 'this scene has no sequence data ya'

part from the code Ideasman42 posted. When I had manually added a new strip it would jump that if statement.

This is all using the standard 2.44 release, no fancy builds from CVS or anything (2.45 is what is up on now). And I don’t know of any API for the sequencer, I just tried the code that Ideasman42 posted and when it didn’t work for me I decided to try doing it with the Scenes module instead of the bpy, and it worked.

Exact same thing here…

When I create the new strip in the sequence of the default scene (‘Scene’) print dir(seq) gives:

But how do you even create a new strip in the sequence?? It refuses to do anything…

EDIT: I just got it partly working. I filtered it all down to this script:

import Blender
from Blender import *
import os


images=[i for i in os.listdir(“C:/Facework”) if i.lower().endswith(".jpg")]“c:/”,images),1,1)

Facework is simply a random directory of pictures I had lying around; insert your own.

It pulls in something that looks like an image sequence, but when I render the sequence, it is just blackness. I made sure it all worked by pulling in the same sequence manually, no problem. But the script returns blackness…

It pulls in something that looks like an image sequence, but when I render the sequence, it is just blackness. I made sure it all worked by pulling in the same sequence manually, no problem. But the script returns blackness…
I had the same problem the first time, it was because I was missing the needed slash at the end of the directory path name.


or as I would need it on my machine

strip ="c:\\",images),1,1)

actually, shouldn’t it be

strip ="c:\\Facework",images),1,1)

as images with contain things like “blah.jpg”, not “Facework\blah.jpg”.

On another note, I got brave and decided to just not worry about deleting strips when I was done with them and just loaded new ones over the old and it worked! In roughly 2 hours I managed to render 256 animations all while watching “Harry Potter: The Goblet of Fire” for like the 5th time on tv. :smiley:

… guess I should get back to writing my thesis and stop playing around in Blender :frowning:

Muahahahaha! I got it!

I was missing a slash; c:/Facework/, not c:/Facework


(now we just need to do the sound thingie…)

being new to python charming etc…

is there a way to manipulate a given sequencer scene with lots of strips like this:

make every single strip twice long as it was
and also maintain the relative position of each strip with the others

i need to do so because i want to avisynth-frameserve deinterlaced clips into my project, substituting the original files with new avis made by makeavis.

I have been working on a Blender-related VSE project (BlenderAVC), and I have been thinking about trying to implement a simple media management system. Is there much documentation about the Python API available for the VSE?

I was working on a Python script today and attempting to add a MOVIE strip to the sequence. Here is my (simplified) script:

from Blender import *

def main():
    scn = Scene.GetCurrent()
    seq = scn.sequence

    # COLOR strip -- works!
    start = 50
    track = 2    
    seq_data = ( 0.5, 0.0, 0.0 )
    strip = seq_data, start, track)

    # MOVIE strip ...
    start = 50
    track = 3
    seq_data = "s:/HomeProjects/NewHF100/2008-08-16/clips/00000.MTS.540p.avs"
    strip = seq_data, start, track)


The COLOR strip works fine, but the MOVIE strip inserts a weird bogus strip that crashes Blender as soon as you try to do anything with it. I looked through the Python sequencer API source code and it looks like the section that deals with movies is simply not coded. My guess is that this part of the API has been used mostly for image sequences.

Anyway, my questions are:

  • Am I correct that this has not yet been implemented?
  • Where can I go to see if there are any existing change requests for this?
  • If I am interested in coding it, who should I talk to about making sure I get it right?As always, thanks to the coders and community for the amazing application!

Hi… I’d also like to jump on this bandwagon. I’m looking to be able to automate video sequence editor changes using python (with blender in background windowless mode)–seems like something a lot of people would find helpful (I’m a bit surprised this hasn’t been done already).

Using a standard install of 2.47, I can’t seem to access any sequence properties or methods. If I do dir(seq), I get:

[‘class’, ‘cmp’, ‘delattr’, ‘doc’, ‘getattribute’, ‘hash’, ‘init’, ‘iter’, ‘new’, ‘reduce’, ‘reduce_ex’, ‘repr’, ‘setattr’, ‘str’, ‘active’, ‘metastrip’, ‘new’, ‘next’, ‘remove’]

but everything seems to be None, including new and active.

I need to be able to add/copy/move/remove strips from the sequence, and also enumerate existing sequence strips and get their properties. Then, of course, I’ll render the sequence.

If there’s an existing movie or image strip, I’d like to be able to replace the underlying asset (or other settings) of the strip without having to remove it and replace it with a new one (though this is a luxury). Something very roughly like:

seq = scn.sequence[1].strip[2].file = “”[1].strip[1].file = “mysound.wav”[2].strip[1].file = "myimage.jpg

I don’t think I’m qualified to make changes to the blender source myself, but I’m happy to help in whatever way I can (especially testing?). And in any case, certainly want to add my voice to others hoping to see sequences fully supported in the api. Can someone (ideasman43?) bring us up to date on the status?