3
$\begingroup$

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?

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

1 Answer 1

4
$\begingroup$

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.ops.render.render(animation=True)

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

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

$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.