save avi files in blender using python script 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?
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.