I'm trying to change the active camera with Python at certain keyframes. An example: render using camera A from frames 1 to 10 and with camera B from 11 to 20, so there would have to be a keyframe at frame 1 and 11.
This is what I have tried so far:
import bpy
scene = bpy.context.scene
cameras = [c for c in bpy.context.scene.objects if c.type == 'CAMERA']
for i, cam in enumerate(cameras):
scene.camera = cam
scene.keyframe_insert(data_path="camera", frame=i)
But this raises the following error:
TypeError: bpy_struct.keyframe_insert() property "camera" not animatable
Note I'm not talking about the Blender game engine like this post was.