I have created an animation using Blender. Does anybody know how I can save .avi file of the rendered animation using a python script?

My second question is that I want to run the animation with different parameters and save the video. Basically, I want to reset the animation and run it again with a new force and save a separate video file. I want to do these automatically instead of manually. Is it possible to do that with scripting?

  • 1
    $\begingroup$ Assume by animation you mean image sequence ? $\endgroup$ – ideasman42 Jun 5 '15 at 2:16
  • 3
    $\begingroup$ Also asking 2 questions at once isn't good, best just ask 2 separate questions. $\endgroup$ – ideasman42 Jun 5 '15 at 2:17

bpy.context.scene.render.filepath contains the filename that the render will be saved to, you can change this and then use bpy.ops.render.render(animation=True) to render the animation to the specified file.

import bpy
bpy.context.active_object.material_slots[0].material = bpy.data.materials['Red']
bpy.context.scene.render.filepath = '//red.avi'

bpy.context.active_object.material_slots[0].material = bpy.data.materials['Blue']
bpy.context.scene.render.filepath = '//blue.avi'

The // at the beginning of the filename puts the file in the same folder as the blend file.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.