Blender Quick Tip: Changing the Camera From the Command Line at Render Time



If you have multiple cameras set up and want to render different views from the command line without manually changing cameras through the UI, it is possible to use a short python script at render time:

Create a file ~/change_camera_script.py

import bpy

bpy.data.scenes["Scene"].camera = bpy.data.objects["CameraName"]

Execute with the following command:

/opt/blender/blender -b ~/BlenderFile.blend --python ~/change_camera_script.py -E CYCLES -S << SceneName >> -s << StartFrame >>  -e << End Frame >> -a --

It works on Windows as well, just change

/opt/blender/blender

to

"c:\Program Files\Blender Foundation\Blender <<Version>>\blender.exe"