I'm writing code to render (assemble) dozens of animations from pre-rendered frames using the video sequence editor.

My workflow that I'm trying to achieve per animation is as follows:

-> Take set of images from folder

-> Add set of images as a singular image strip into the VSE

-> Render said image strip as an .avi file and save to same folder where the images are taken from

-> Reverse image strip's frames for reversed version of animation

-> Render and save again

This process will be iterated in a for loop, but right now I'm trying to test it on a single folder to get the process working first.

Here is my code, I will describe what the problem is after:

import os
import shutil
import bpy

img_dir = r'D:\TTITF\Game Files and Animations\Animations\Bridges\Walk ~ Alvie - V_2 R TRIMMED - Copy\V_O to V_4'

frame_duration = len(os.listdir(img_dir))
files0 = [f for f in os.listdir(img_dir) if os.path.isfile(os.path.join(img_dir, f))]
files00 = []

for f in files0:
    filename, file_ext = os.path.splitext(f)

files = sorted(files00)
scene = bpy.context.scene
sed = scene.sequence_editor_create()
seq = sed.sequences
duration = len(files) - 1
fp = files.pop(0)
imstrip = seq.new + image(
while files:
imstrip.frame_final_duration = duration

Files0 creates a list of files from the folder.

Then each file in that list is appended to another one without its extension.

So that way the files are just numbers, "6120", "3187", etc... instead of "6120.png" "3187.png"...

Then they are sorted for the rendering process.

The rest of the code, I took from another question on here (can't find it rn), so I don't know exactly how all of it works.

But when I attempt to run it as a script in Blender, I get an error message on the System Console:

enter image description here

How do I deal with this issue? Are there certain libraries or information I need to import for this?

I've finished a couple of python scripts on Pycharm, but I don't know what to look out for when coding python for Blender. (I'm new to python coding in general)


EDIT: While I haven't figured out how to fix the specific error here, I have figured out a work-around to achieve what I was originally trying to do.

import os
import bpy

img_dir = r'D:\TTITF\Game Files and Animations\Animations\Bridges\Walk ~ Alvie - V_2 R TRIMMED - Copy\V_O to V_4'

files = [f for f in os.listdir(img_dir) if os.path.isfile(os.path.join(img_dir, f))]
frame_duration = len(files)
filepath = os.path.join(img_dir, str(files[0]))

context = bpy.context
scene = context.scene
sed = scene.sequence_editor
sequences = sed.sequences

frame_start = 0
frame_end = 1

image_strip = sequences.new_image("IM Strip", filepath, 1, frame_start)

image_strip.frame_final_end = frame_end

for f in files:

I was originally trying to create the full image strip with all its contents all at once like I would manually, but instead I added just the first image as an image strip and then appended the rest of the images to it instead. For me, this manages to produce the right result.

  • $\begingroup$ I think you want to call the function seq.new() rather than access seq.new as a variable, but I think that's still not enough to give you imstrip $\endgroup$ Mar 27, 2022 at 20:27
  • $\begingroup$ I tried putting in seq.new() instead of seq.new, but it gave me the same error $\endgroup$ Mar 27, 2022 at 23:14
  • $\begingroup$ Okay, I've done a lot more digging and still cannot find a solution for the this general problem. This code looked promising, but I have no idea how to make implement the set of files I defined. It just tells me that it needs to be a "dict" or an "RNA" collection, which are things I do not know how to make or deal with. learnsharewithdp.wordpress.com/2018/08/27/… $\endgroup$ Mar 30, 2022 at 0:45
  • $\begingroup$ I was also looking at this question: blender.stackexchange.com/questions/39854/… But even if I use the last part of the answer, I ultimately cannot define what "scene" is after a bit of research. This is really mindboggling, and I hope I can find some kind of solution, whether it be in 2.79 or 2.8+ $\endgroup$ Mar 30, 2022 at 0:47
  • $\begingroup$ I'm sorry, I haven't time to dig into VSE from python; but this might help you get a start. $\endgroup$ Mar 30, 2022 at 0:49


You must log in to answer this question.

Browse other questions tagged .