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)
files00.append(filename)
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(
name=fp.name,
filepath=str(fp),
frame_start=0,
channel=1,
)
while files:
imstrip.elements.append(files.pop(0).name)
imstrip.frame_final_duration = duration
imstrip.update()
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:
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]))
files.pop(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:
image_strip.elements.append(f)
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.

seq.new()rather than accessseq.newas a variable, but I think that's still not enough to give youimstrip– Marty Fouts Mar 27 '22 at 20:27seq.new()instead ofseq.new, but it gave me the same error – Krillinslosingstreak Mar 27 '22 at 23:14