I’m trying to use the callback method to post the render file when it’s ready, but it seems to be running the callback function before the render is finished, any ideas? about how to wait the render finish to execute a function ?
def render(level_map, master_sequence, sequence, start_frame, end_frame, output_path, file_name, project_check_in ):
level_sequencer = unreal.LevelSequence( unreal.load_asset(sequence) )
# Get movie queue subsystem for editor.
subsystem=unreal.get_editor_subsystem(unreal.MoviePipelineQueueSubsystem)
q=subsystem.get_queue()
executor=unreal.MoviePipelinePIEExecutor()
#Get movie queue subsystem for editor.
mpqSubsystem=unreal.get_editor_subsystem(unreal.MoviePipelineQueueSubsystem)
queue=mpqSubsystem.get_queue()
job = queue.allocate_new_job(unreal.MoviePipelineExecutorJob)
# #Create new movie pipeline job
job.map=unreal.SoftObjectPath(level_map)
job.sequence=unreal.SoftObjectPath(master_sequence)
job.job_name=file_name#job_name
# Create shot and add it to the job
job_shot = unreal.MoviePipelineExecutorShot(level_sequencer)
job_shot.outer_name = level_sequencer.get_name()
job_shot.inner_name = sequence
job_shot.enabled = True
job.shot_info = [job_shot]
c=unreal.MoviePipelineMasterConfig()
# Job output settings
output_setting = c.find_or_add_setting_by_class(unreal.MoviePipelineOutputSetting)
output_setting.output_directory = unreal.DirectoryPath(output_path)
output_setting.file_name_format = file_name
output_setting.output_resolution= 480, 640#1920, 1080
output_setting.use_custom_playback_range = True
output_setting.custom_start_frame = start_frame
output_setting.custom_end_frame = end_frame
# Job encoding settings
proRes = c.find_or_add_setting_by_class(unreal.MoviePipelineAppleProResOutput)
proRes.codec = unreal.AppleProResEncoderCodec.PRO_RES_422_PROXY
# Ensure deferred rendering on job so lights are properly rendered
c.find_or_add_setting_by_class(unreal.MoviePipelineDeferredPassBase)
# Use high res settings
highResSettings = c.find_or_add_setting_by_class(unreal.MoviePipelineHighResSetting)
highResSettings.texture_sharpness_bias = -0.1
job.set_configuration(c)
error_callback=unreal.OnMoviePipelineExecutorErrored()
def movie_error(pipeline_executor,pipeline_with_error,is_fatal,error_text):
print(pipeline_executor)
print(pipeline_with_error)
print(is_fatal)
print(error_text)
error_callback.add_callable(movie_error)
def movie_finished(pipeline_executor,success):
print(pipeline_executor)
print(success)
project_check_in() # Publish function, passed on arguments
finished_callback=unreal.OnMoviePipelineExecutorFinished()
finished_callback.add_callable(movie_finished)
executor = mpqSubsystem.render_queue_with_executor(unreal.MoviePipelinePIEExecutor)
if executor:
executor.set_editor_property('on_executor_errored_delegate',error_callback)
executor.set_editor_property('on_executor_finished_delegate',finished_callback)