# Blender Crashes after a few Renders from a Batch Script

On Windows 7 I am rendering a series of animations from Blender in a batch script that looks like this:

call "C:\Program Files\Blender Foundation\Blender\blender.exe" -b "E:\Project.blend" -S Scene1 -o "E:\exports\Fredericksburg1\Fredericksburg1_" -F JPEG -s 001 -e 435 -a
call "C:\Program Files\Blender Foundation\Blender\blender.exe" -b "E:\Project.blend" -S Scene2 -o "E:\exports\Fredericksburg2\Fredericksburg2_" -F JPEG -s 001 -e 480 -a
call "C:\Program Files\Blender Foundation\Blender\blender.exe" -b "E:\Project.blend" -S Scene3 -o "E:\exports\Fredericksburg3\Fredericksburg3_" -F JPEG -s 001 -e 180 -a


My problem is that after rendering one or two files, the rest of the Blender instances crash immediately after reading the preferences. The crash file just has this:

# Blender 2.69 (sub 0), Revision: 60995


It is not related to which project I use, usually only the first one or two render. I have tried a few things, making sure the computer didn't go to sleep or even the screen go blank, play around with the .bat file, but I haven't been able to get anything to consistently work. Any ideas?

You could change from a batch script to a python script. You can call the python script on startup by adding a parameter to the call like so:

call "C:\Program Files\Blender Foundation\Blender\blender.exe" -b "E:\Project.blend" -P pythonScript.py


the python script would look somewhat like this:

pythonScript.py:

import bpy
from bpy.app.handlers import persistent

renderInformation = {
'Scene1': (r'E:\exports\Fredericksburg1\Fredericksburg1_', [1, 435], 'JPEG'),
'Scene2': (r'E:\exports\Fredericksburg2\Fredericksburg2_', [1, 480], 'JPEG'),
'Scene3': (r'E:\exports\Fredericksburg3\Fredericksburg3_', [1, 180], 'JPEG'),}
# you can use any slash and just copy-paste the path from the explorer
# as long as it doesn't end with a "\'"

@persistant
def callbackFunc(context=None):
try:
sceneIdent, info = renderInformation.popitem() # get the next scene to render
scene = bpy.data.scenes[sceneIdent] # get the actual scene
bpy.context.screen.scene = scene # set the scene
(scene.render.filepath,
(scene.frame_start, scene.frame_end),
scene.render.image_settings.file_format) = info # extract information
bpy.ops.render.render(animation=True) # render as animation
except:
pass # then the list is exhausted and we can end the process

if __name__ == "__main__":
if callbackFunc not in bpy.app.handlers.render_complete:
bpy.app.handlers.render_complete.append(callbackFunc) # we register a callback after each render
callbackFunc() # and call it ourselves at first


This just keeps blender down to one instance and might be worth considering anyways if you want to get deeper into the action, with more scenes to render etc. A batch script for that seems quite irrational, idk :)

I hope this fixes the problem for you, if not, then you might consider taking a look at your CPU-loading, maybe your scenes are just too big :? I don't think so since two render good but you never know. Tell me if there is anything you're interested about or if the proposed "solution" doesn't work.

• Thanks for the answer. I'm nearly certain it's not a CPU issue, the scenes are very simple and it's a powerful computer. – hornj Jan 25 '14 at 2:34
• When I run with the python script, I get the error, NameError: name 'callbackFunc' is not defined'. When I move the definition of the function up, I get the error callbackFunc() missing 1 required positional argument: 'self' Any idea what the problem is? Thanks. – hornj Jan 25 '14 at 2:36
• I misinterpreted the argument :) you get the current scene passed. As you are not interested in that you can call it with None in "main" – WorldSEnder Jan 25 '14 at 2:43
• Thanks for that. Now when I run it goes into callbackFunc, sets the parameters correctly, but does not actually render. – hornj Jan 25 '14 at 2:57
• Any chance to make progress? – hornj Jan 25 '14 at 21:32