3
$\begingroup$

I need help with the python api for setting the video encoding in Blender 2.79a.

I have already set the output type to FFMPEG via:

bpy.data.scenes["Scene"].render.image_settings.file_format = 'FFMPEG'

I now need to set the encoding to output video in MP4 format and haven't been able to find this information yet.

Thanks

$\endgroup$
5
$\begingroup$

Set Output.file_format to FFMPG and adjust the attributes of Render.ffmpeg:

import bpy

scene = bpy.context.scene
rd = scene.render

# Set output type
rd.image_settings.file_format = "FFMPEG"

# Set output format
rd.ffmpeg.format = "MPEG4"

# Set the codec
rd.ffmpeg.codec = "H264"

...

Other options:

  • codec: MPEG1, MPEG2, MPEG4, HUFFYUV, DV, H264, THEORA, DNXHD, PNG
  • format: MPEG1, MPEG2, MPEG4, AVI, QUICKTIME, DV, H264, XVID, OGG, MKV
  • video_bitrate: 0 - infinity (integer)
  • maxrate: 0 - infinity (integer)
  • audio_channels: MONO, STEREO, SURROUND4, SURROUND51, SURROUND71
  • audio_bitrate: 32 - 384

For all available options, see the API on FFmpegSettings.

$\endgroup$
1
$\begingroup$

I ended up finding the solution in this post

To set the individual settings for ffmpeg use:

bpy.data.scenes["Scene"].render.ffmpeg.<SETTING_TO_MODIFY>

For example to set settings to use H264 with MP4 container:

    bpy.data.scenes["Scene"].render.ffmpeg.format = "MPEG4"
    bpy.data.scenes["Scene"].render.ffmpeg.codec = "H264"
    bpy.data.scenes["Scene"].render.ffmpeg.constant_rate_factor = "MEDIUM"
    bpy.data.scenes["Scene"].render.ffmpeg.ffmpeg_preset = "MEDIUM"
$\endgroup$

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.