Introduction
In this post, I’ll cover Python automation using Movie Render Queue (MRQ) and Movie Scene Capture.
I’ll go over how to make Python tools to run in the Unreal Editor as well as outside Unreal through command line; How to change settings and add call backs.
The MRQ is more preferred over Movie Scene Capture as it’s much more customizable, both in supported render setting and in automation (In a later post you’ll see).
Movie Render Queue
Movie Render Queue is a successor to the Sequencer Render Movie feature, and is built for higher quality, easier integration into production pipelines, and user extensibility. With Movie Render Queue you can accumulate multiple render samples together to produce the final output frame, which allows for higher quality anti-aliasing, radial motion blur, and reduced noise in ray tracing.
The Movie Render Queue (MRQ) is the latest and the greatest from Unreal for Rendering out cinematic, over the legacy Movie Scene Capture Tool.
Movie Render Queue in Editor
Here we can find the full example from Epic:
Engine\Plugins\MovieScene\MovieRenderPipeline\Content\Python\MoviePipelineEditorExample.py
Bare Minimal
Through Unreal Editor, we use a render executor called PlayInEditor (PIE) executor.
1 | def movie_queue_render(u_level_file, u_level_seq_file, u_preset_file): |
Override Settings
All the render settings are stored as an unreal.MoviePipelineMasterConfig
object.
It has sub setting components class unreal.MoviePipeline
, for example: unreal.MoviePipelineOutputSetting
,
unreal.MoviePipelineCameraSetting
, unreal.MoviePipelineColorSetting
and etc
Each Setting class then have properties, for unreal.MoviePipelineOutputSetting
, it has
properties such as:
use_custom_frame_rate
frame_number_offset
output_directory
- etc
All of which can be modified, attached, and removed.
Example:
1 | uPreset = unreal.MoviePipelineMasterConfig() |
Callback
Callbacks can be added upon each Shot, Job, Queue Finished. The callback function has to be kept as global variable here to prevent it being destroyed by GC.
1 | def render_finished(params): |
or.
1 | def render_errored(executor, pipeline, is_fatal, error_msg): |
See my convenient class for PIE here: https://github.com/leixingyu/unrealUtil/blob/master/render/render.py
Movie Render Queue Commandline
The default MRQ command line offers customization by using either an Unreal Render Preset/Config asset or an Unreal Render Queue asset.
Since there are so many settings in the MRQ we can modify, it’s hard to expose all of the little details through command line. If you do wish to do so, I have an entire blog about Unreal MRQ Custom Executor.
1 | def movie_queue_render(u_level_file, u_level_seq_file, u_preset_file): |
Movie Scene Capture
Now this part may or may not be relevant anymore as many people treats the Movie Scene Capture as deprecated. But I thought I write it down anyway, as it might be helpful as a comparison to MRQ
Movie Scene Capture Editor
Here we can find an example from Epic:
Engine\Plugins\MovieScene\SequencerScripting\Content\Python\sequencer_examples.py
Bare Minimal
1 | import unreal |
In this example, we only need to supply the path to the Unreal sequencer asset.
Note that the render happens in the current level, so make sure to pre-load the map before running the Movie Scene Capture.
Callback
1 | def on_render_movie_finished(success): |
Note the on_finished_callback
is a global variable so it is persistent and won’t
get destroyed during GC.
The next step is to register the callback function:
unreal.SequencerTools.render_movie(capture_settings, unreal.OnRenderMovieStopped())
Override Setting
The settings can be modified through class unreal.MovieSceneCaptureSettings
Example:
1 | capture = unreal.AutomatedLevelSequenceCapture() |
Movie Scene Capture Commandline
A lot of custom flags can be specified through the command line, see the full list of control commands: Command Line Arguments for Rendering Movies
Console variables can even be set through command line which is decent.
1 | import subprocess |
Additional References
Unreal Forums - Unable to execute MoviePipelineQueue from Python