Within your scene loop you can alter the render settings within scene.render
Some variables of interest may be -
render.image_settings.file_format
default available image_format options are BMP IRIS PNG JPEG TARGA TARGA_RAW OPEN_EXR_MULTILAYER OPEN_EXR AVI_JPEG AVI_RAW - depending on the build settings others may be available, like CINEON DPX TIFF or FFMPEG
If you have the FFMPEG option then you can adjust it through variables in scene.render.ffmpeg
such as scene.render.ffmpeg.codec
with options like H264 or MPEG4. Other ffmpeg variables include video_bitrate maxrate minrate packetsize
To change the framerate set scene.render.fps
To specify where the file is saved you set scene.render.filepath
One point to consider is that bpy.ops.render.render
will render using the settings saved with the file, so you can setup these options and save before starting your python script.
It is also common to render animations to individual files for each frame and then join them into a video file once rendering has completed. One way to do this is with ffmpeg as described here another is to import the image sequence into blender's video sequence editor and 'render' to a video file, this is very quick once all the images have been rendered. The blender wiki can get you started.
Blender is a large beast and the python dataset to access it all is just as large. You can find a large amount of information in the blender API documentaion but you may find blender and it's built-in python console just as helpful. You can right click on almost any interface item and select Edit Source
- this will open the python file used to display that item in a text block (available in a text editor window) with the cursor on the relevant line.
Within the blender python console you can enter bpy.data.scenes['Scene'].render.ffmpeg.
and click the Autocomplete button to see a list of variables and functions available as the next item.
Also don't forget that if it has been turned off you can turn on python tooltips in the user settings, which displays some python paths (sometimes truncated) in the tooltips for most things, that can at least point you in the direction to look for more information.