I have a baffling problem. I am using a blender python script to automatically take rendered images from folders, turn them into image sequences in the video sequence editor, and output them to the same folder the images were in as a video, which usefully requires much less storage space than all the images combined.

This script worked fine, and continues to work good, except for, for some reason, the first 951 frames of my animation(s).

enter image description here

What I mean is, for this specific animation folder set I have screenshotted above, I have roughly 5000 frames, and when most of these are organized and put through the python script in the blender VSE and rendered to a video, they come out good, and contain the images the folders have.

However, any videos that contain the first 951 frames, render as a completely black video.

At first, I thought it might be a permissions thing, where my script isn't able to access those files, and so I checked the properties of one of the frames in that set, and their properties were identical to those of later frames that rendered correctly.

Then I thought it was the folder permissions, but there's nothing wrong there either. They are .PNG files, and they should follow the rest of the files in outputting correctly. But they don't, and I do not know why.

I even ran a python script to explicitly tell me if their permissions were good, and each result came out true. I deleted and recopied those specific frames from the source, no effect. I tried the same frames but from another drive, nothing changed. I even tried to use the script, but on a completely new blender file at default settings, without any potential left over issues from anything I did previously, it still rendered as a completely black video.

enter image description here

And the strangest thing is, when I manually add an image strip containing these same files and render it manually, the result is correct!

enter image description here

These are my output settings:

enter image description here

There is an issue somewhere in the pipeline. If it is just my code, why do other sets of images render fine?

enter image description here

If the problem lies only in the image frames in question, why do they render correctly when done manually without the script?

Why are only the first 951 frames (the first continuous set of integer filenames, the very next image file jumping to 2068.png), affected?

enter image description here

I don't know, but here is my script I've been using and talking about. Please tell me if you can find anything wrong with it, or if there's some built-in mechanism that prevents outputting frames until 951 images has passed...

import os
import bpy

img_dir = r'D:\TTITW\night3 Animation Finals\Empty-Walk (night3) TRIMMED\V_O to V_4'

filesw = [f for f in os.listdir(img_dir) if os.path.isfile(os.path.join(img_dir, f))]

frameend = len(filesw) - 1

i = 0
for f1 in filesw:
    filename, file_ext = os.path.splitext(f1)
    if file_ext == ".avi":
    i += 1

filex = []

for f11 in filesw:
    filename, file_ext = os.path.splitext(f11)

filey = [int(x) for x in filex]


filez = [str(y) for y in filey]

files = [s + ".png" for s in filez]

filepath = os.path.join(img_dir, str(files[0]))
filesR = files

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:

bpy.data.scenes["Scene"].render.filepath = img_dir + "\\"

bpy.data.scenes["Scene"].frame_start = 0
bpy.data.scenes["Scene"].frame_end = frameend

bpy.ops.render.render(animation=True, use_viewport=True)


If I can't find a solution this, I'll need to sit down and do the rendering manually, it's probably manageable, but I'd prefer not to have to do that, since I've got about 54 animation sets, any one with possibly nine folders that have this problem. Also, this is such a confounding problem I've encountered, that it's probably good to understand just what is causing it.

If there's anything in the VSE or Blender that might cause something like this, please let me know. I'm on version 3.1.

Thank you for reading this! Try it yourself if you'd like, but please help if you can!


2 Answers 2


I found an issue in the script, that may lead to blank frames. Then you sort by converting to int, you lose leading digits, so 0001.png becomes 1.png. Broken links should lead to blank frames.

You may replace sorting by something like this:

import re

def natural_sort(l): 
    convert = lambda text: int(text) if text.isdigit() else text.lower()
    alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
    return sorted(l, key=alphanum_key)

filez = natural_sort(filex)

files = [s + ".png" for s in filez]
  • 1
    $\begingroup$ That's a good catch! $\endgroup$ Nov 10, 2022 at 10:37
  • $\begingroup$ That is exactly it. I integrated your code into my script, and it produced the video correctly. Thank you so much! I would not have caught that any time soon. I should have probably checked what was being created at each stage of the process. $\endgroup$ Nov 11, 2022 at 3:53

I don't know if it solves your problem, but perhaps tweaking the strip start, end and duration in your script could help. Then it looks like when you add a strip manually.

# Blender default: timeline starts at 1
frame_start = 1
frame_end = len(files)

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

for f in files:

# Setting end frame and frame duration (just to be safe)
image_strip.frame_final_end = frame_end
image_strip.frame_final_duration = frame_end - frame_start + 1

# Make sure Blender is up to date before rendering

# And render...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .