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.

  • 3
    $\begingroup$ You can't directly animate this property but you can bind cameras to specific markers. See blender.stackexchange.com/a/43773/86891 $\endgroup$
    – Gorgious
    Nov 9, 2021 at 15:56
  • $\begingroup$ @Gorgious That did the trick, thank you! $\endgroup$
    – cegredev
    Nov 10, 2021 at 9:59


Browse other questions tagged .