So I have a fairly simple method in my blender python script that either renders and saves an individual frame or renders an animation given a frame range. Now the former option works perfectly, the frame lands where it should be in the newly created folder and everything is fine. The latter, not so much:
For some reason, Blender saves the animation frames twice, once in the newly created folder with the name specified by output_path as it should and once, for some damn reason, in the parent folder above WITHOUT the frame name (just the usual 000X.exr). I should mention that I have just one output node with multi-layered OpenEXR that has an Image channel and a depth channel. I've tried different combinations for the parameters of bpy.ops.render.render and also confirmed it is only this line causing this since it doesn't render or save anything if I comment it out. Obviously I call this method with animation=True when this problem occurs.
I'd appreciate it if you could explain to me why it does that or where the source code for this damn function is.
def render_frame_and_save(output_name, animation=False, start=0,end=240):
#Determine incremental output path
i = 0
while os.path.exists(output_path + '{:03d}'.format(i)):
i +=1
path = output_path + '{:03d}'.format(i)
os.makedirs(path )
bpy.context.scene.render.filepath = path + "/" + output_name
if animation:
bpy.context.scene.frame_start = start
bpy.context.scene.frame_end = end
bpy.ops.render.render(animation=True)
else:
bpy.ops.render.render(write_still = True)
#Dump config
cfg_file = open(path + '/samples.cfg', 'w')
cfg_file.write('time: ' + datetime_str) #TODO Add config
cfg_file.close()
Scene.frame_set(frame_number)before calling the operator, example: https://blender.stackexchange.com/a/27640/31447 – brockmann Mar 27 '20 at 14:54frame_set()calls a C function which is most likely the same function that will be called internally when rendering as animation. Again, we can test it. However, the discussion is pointless IMHO, because the render engine can only render a single frame anyway... – brockmann Mar 31 '20 at 13:43