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).
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.
And the strangest thing is, when I manually add an image strip containing these same files and render it manually, the result is correct!
These are my output settings:
There is an issue somewhere in the pipeline. If it is just my code, why do other sets of images render fine?
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?
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":
filesw.pop(i)
i += 1
filex = []
for f11 in filesw:
filename, file_ext = os.path.splitext(f11)
filex.append(filename)
filey = [int(x) for x in filex]
filey.sort()
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
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)
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)
sequences.remove(image_strip)
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!