Render from command line

Blender 2.63a

You can render a scene without opening the blender interface from command line

in windows – cmd
in linux or mac – terminal

Provided everything is set and ready to be rendered, to render animation type in command

blender -b filename.blend -a

For more advance options, you can use python script to change some settings in the blend file before render.

Create an empty text file with your favorite text editor (or in blender). Copy & paste these example settings.

import bpy

#change scene name to yours
Scenename = 'Scene'

# quality
bpy.data.scenes[Scenename].render.resolution_x = 2048
bpy.data.scenes[Scenename].render.resolution_y = 1080
bpy.data.scenes[Scenename].render.resolution_percentage = 50
bpy.data.scenes[Scenename].render.use_antialiasing = True
#bpy.data.scenes[Scenename].render.use_full_sample = True

# frame range
#bpy.data.scenes[Scenename].frame_start = 1
#bpy.data.scenes[Scenename].frame_end = 5

# image format
bpy.data.scenes[Scenename].render.image_settings.file_format = 'TIFF'
bpy.data.scenes[Scenename].render.image_settings.quality = 80
bpy.data.scenes[Scenename].render.image_settings.color_mode = 'RGBA'

# Cycles sampling
#bpy.data.scenes[Scenename].cycles.samples = 200

# stamp
bpy.data.scenes[Scenename].render.use_stamp = 1
bpy.data.scenes[Scenename].render.stamp_background = (0,0,0,1)

# output
#bpy.data.scenes[Scenename].render.filepath = '//render/test_'
bpy.data.scenes[Scenename].render.use_placeholder = True
bpy.data.scenes[Scenename].render.use_overwrite = False

# start render animation
bpy.ops.render.render(animation=True,scene=Scenename)

The important lines are the first and the last. Other lines can be changed to fit your need. The properties names are quite self-explained. The # sign is for comment line, will be ignored by the interpreter. You can hover the mouse over any boxes or buttons in Blender to see the script associated.

More details can be found at blender python api reference :

http://www.blender.org/documentation/blender_python_api_2_63_2/contents.html

 

Save the text as ‘setting.py’. You might put it in the same folder as the blend file for convenient.

To start render from command line, type

blender -b filename.blend -P setting.py