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(write_still = True)

    #Dump config
    cfg_file = open(path + '/samples.cfg', 'w')
    cfg_file.write('time: ' + datetime_str) #TODO Add config

So if anyone stumbles over this: I did find out what caused it

A bit unintuitively, Blender automatically saves animation but not single frames. I assumed that after I removed the default composite node (after activation nodes) in the Composition View, Blender would not save anything out of my designated output nodes. But well, it still does (but again, only when you render animations).

Edit (27-03-2020): To make it a bit clearer, the problem is that while you can choose not to save the output when rendering frames, Blender WILL saved rendered animations regardless of your dedicated output nodes. The option not to save this animation output (in addition to your output nodes) seems to be missing.

There also doesn't seem an obvious way of preventing Blender from doing so which is quite annoying.

  • $\begingroup$ "Blender saves animation but not single frames?" It's the same operator, nothing annoying... You just have to set the frame Scene.frame_set(frame_number) before calling the operator, example: blender.stackexchange.com/a/27640/31447 $\endgroup$ – brockmann Mar 27 '20 at 14:54
  • $\begingroup$ Dude, you really missed the point. I have no trouble saving either animation or frames, the trouble is that when you choose animation=True, Blender will save the animation regardless of your output nodes whereas if you render frames, you can choose not to save it (since you save it with your output nodes anyway). Your link doesn't really seem to have to do anything with it. $\endgroup$ – Megamind Mar 27 '20 at 15:24
  • $\begingroup$ Render to single frames dude, no need for "animation=True" - see my example... $\endgroup$ – brockmann Mar 27 '20 at 15:29
  • $\begingroup$ Obviously I can render frame by frame, but since I then have to Python-loop over all frames I want, I suspect it'll slow down my code significantly as I aim to produce a very large dataset. Right now, I just use the "native output" from Blender and additionally other output nodes. I'd rather have all output streams in the Compositing view, but well. I still don't understand why the "native output" isn't just another node, especially considering the default nodes. $\endgroup$ – Megamind Mar 27 '20 at 15:37
  • $\begingroup$ We can look into the c source or test whether this slows down the rendering. However, the frame needs to be set anyway (to update the scene) and my example shows the common way of rendering an animation via python so I'm sure there is absolutely no difference performance wise... but yeah can be tested. Re your other/actual question: I guess there is something wrong with your comp. Could you add an image or preferably a simplified blend file of your comp using blend-exchange.giantcowfilms.com ? $\endgroup$ – brockmann Mar 28 '20 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.