I have a render task that I want to automate with Python and running from command line.
The idea is to run an -ExecutePythonScript that will start the render, wait for the render to finish and then exit the engine.
.\UnrealEditor-Cmd.exe Project.uproject -ExecutePythonScript="runrender.py" -Log -StdOut -allowStdOutLogVerbosity
BUT
As far as I understand as soon as the script supplied with ExecutePythonScript is finished, the editor receives an exit command, while the MoviePipelinePIEExecutor is still doing its job. Blocking the script with let’s say endless loop blocks the engine and it just hangs.
Is there a way to prevent editor from exiting on script finish? Or prevent engine from blocking when the script is blocking?
Here is a simplified script I would like to run (it runs smoothly from the running editor):
import unreal
def start_movie_pipeline_queue(queue_path):
unreal.log(f"STARTED")
movie_pipeline_queue_asset = unreal.load_asset(queue_path, unreal.MoviePipelineQueue)
if not movie_pipeline_queue_asset:
unreal.log_error(f"Failed to load Movie Pipeline Queue at {queue_path}")
return
movie_pipeline_queue_subsystem = unreal.get_editor_subsystem(unreal.MoviePipelineQueueSubsystem)
movie_pipeline_queue_subsystem.load_queue(movie_pipeline_queue_asset, prompt_on_replacing_dirty_queue=False)
executor = unreal.MoviePipelinePIEExecutor()
movie_pipeline_queue_subsystem.render_queue_with_executor_instance(executor) # or use MoviePipelineExecutorBase for headless mode if needed
if executor:
pp_finished_inst = unreal.OnMoviePipelineExecutorFinished()
def pp_finished_handler(one, two):
unreal.log(f"FINISHED YOYO")
pp_finished_inst.add_callable(pp_finished_handler)
executor.set_editor_property('on_executor_finished_delegate',pp_finished_inst)
unreal.log(f"PROP SET")
else:
unreal.log_error(f"Failed to load Executor")
start_movie_pipeline_queue("/Game/Cinematics/RenderSettings/Only_MasterSQ_queue")
Thanks!