I was hoping to render blender using the command line mode on linux. However, I do not no how to set the output resolution and H.264 as the encoding. Both these options work in the GUI mode but I wish to use them from the command line
One way is to set the properties from the gui, save the file, then render. The settings will be preserved for rendering from the command line.
Note that (as already mentioned by iKlsR) you can set the render output format from the command line with
Format Options: -F or --render-format <format> Set the render format, Valid options are... TGA IRIS JPEG MOVIE IRIZ RAWTGA AVIRAW AVIJPEG PNG BMP FRAMESERVER (formats that can be compiled into blender, not available on all systems) HDR TIFF EXR MULTILAYER MPEG AVICODEC QUICKTIME CINEON DPX DDS
However, it seems
H264 is not a valid setting for this argument.
blender --background /path/to/file.blend --python /path/to/script.py --render-anim
blender -b /path/to/file.blend -P /path/to/script.py -a
The output format can be set to H.264 with
bpy.context.scene.render.image_settings.file_format = 'H264'.
Note on scene values:
You may want to assign the settings for all scenes to avoid confusion with complex setups which use multiple scenes.
for scene in bpy.data.scenes: scene.render.resolution_x = 1920 scene.render.resolution_y = 1080 scene.render.image_settings.file_format = 'H264'
Note invoking render:
When using a Python script to render you have the choice to...
- Pass the
bpy.ops.render.render(animation=True)directly from the Python script.
Both do the same thing however calling the operator from Python means if the script fails to run, render won't execute, This may be good/bad depending on your use-case.
Calling from Python also gives some flexibility - for example you could call render multiple times with different frame ranges.