@@ -541,11 +541,23 @@ def publish(self, settings, item):
541
541
self .logger .info ("Rendering %s with the Movie Render Queue with %s presets." % (publish_path , presets .get_name ()))
542
542
else :
543
543
self .logger .info ("Rendering %s with the Movie Render Queue." % publish_path )
544
- self ._unreal_render_sequence_with_movie_queue (publish_path , unreal_map_path , unreal_asset_path , presets )
544
+ res , _ = self ._unreal_render_sequence_with_movie_queue (
545
+ publish_path ,
546
+ unreal_map_path ,
547
+ unreal_asset_path ,
548
+ presets
549
+ )
545
550
else :
546
551
self .logger .info ("Rendering %s with the Level Sequencer." % publish_path )
547
- self ._unreal_render_sequence_with_sequencer (publish_path , unreal_map_path , unreal_asset_path )
548
-
552
+ res , _ = self ._unreal_render_sequence_with_sequencer (
553
+ publish_path ,
554
+ unreal_map_path ,
555
+ unreal_asset_path
556
+ )
557
+ if not res :
558
+ raise RuntimeError (
559
+ "Unable to render %s" % publish_path
560
+ )
549
561
# Increment the version number
550
562
self ._unreal_asset_set_version (unreal_asset_path , item .properties ["version_number" ])
551
563
@@ -696,50 +708,47 @@ def _unreal_render_sequence_with_sequencer(self, output_path, unreal_map_path, s
696
708
return False , None
697
709
698
710
# Render the sequence to a movie file using the following command-line arguments
699
- cmdline_args = []
700
-
701
- # Note that any command-line arguments (usually paths) that could contain spaces must be enclosed between quotes
702
- unreal_exec_path = '"{}"' .format (sys .executable )
703
-
704
- # Get the Unreal project to load
705
- unreal_project_filename = "{}.uproject" .format (unreal .SystemLibrary .get_game_name ())
706
- unreal_project_path = os .path .join (unreal .SystemLibrary .get_project_directory (), unreal_project_filename )
707
- unreal_project_path = '"{}"' .format (unreal_project_path )
708
-
709
- # Important to keep the order for these arguments
710
- cmdline_args .append (unreal_exec_path ) # Unreal executable path
711
- cmdline_args .append (unreal_project_path ) # Unreal project
712
- cmdline_args .append (unreal_map_path ) # Level to load for rendering the sequence
713
-
714
- # Command-line arguments for Sequencer Render to Movie
715
- # See: https://docs.unrealengine.com/en-us/Engine/Sequencer/Workflow/RenderingCmdLine
716
- sequence_path = "-LevelSequence={}" .format (sequence_path )
717
- cmdline_args .append (sequence_path ) # The sequence to render
718
-
719
- output_path = '-MovieFolder="{}"' .format (output_folder )
720
- cmdline_args .append (output_path ) # output folder, must match the work template
721
-
722
- movie_name_arg = "-MovieName={}" .format (movie_name )
723
- cmdline_args .append (movie_name_arg ) # output filename
724
-
725
- cmdline_args .append ("-game" )
726
- cmdline_args .append ("-MovieSceneCaptureType=/Script/MovieSceneCapture.AutomatedLevelSequenceCapture" )
727
- cmdline_args .append ("-ResX=1280" )
728
- cmdline_args .append ("-ResY=720" )
729
- cmdline_args .append ("-ForceRes" )
730
- cmdline_args .append ("-Windowed" )
731
- cmdline_args .append ("-MovieCinematicMode=yes" )
732
- cmdline_args .append ("-MovieFormat=Video" )
733
- cmdline_args .append ("-MovieFrameRate=24" )
734
- cmdline_args .append ("-MovieQuality=75" )
735
- cmdline_args .append ("-NoTextureStreaming" )
736
- cmdline_args .append ("-NoLoadingScreen" )
737
- cmdline_args .append ("-NoScreenMessages" )
738
-
739
- unreal .log ("Sequencer command-line arguments: {}" .format (cmdline_args ))
740
-
741
- # Send the arguments as a single string because some arguments could contain spaces and we don't want those to be quoted
742
- subprocess .call (" " .join (cmdline_args ))
711
+ cmdline_args = [
712
+ sys .executable , # Unreal executable path
713
+ "%s" % os .path .join (
714
+ unreal .SystemLibrary .get_project_directory (),
715
+ "%s.uproject" % unreal .SystemLibrary .get_game_name (),
716
+ ), # Unreal project
717
+ unreal_map_path , # Level to load for rendering the sequence
718
+ # Command-line arguments for Sequencer Render to Movie
719
+ # See: https://docs.unrealengine.com/en-us/Engine/Sequencer/Workflow/RenderingCmdLine
720
+ #
721
+ "-LevelSequence=%s" % sequence_path , # The sequence to render
722
+ "-MovieFolder=%s" % output_folder , # Output folder, must match the work template
723
+ "-MovieName=%s" % movie_name , # Output filename
724
+ "-game" ,
725
+ "-MovieSceneCaptureType=/Script/MovieSceneCapture.AutomatedLevelSequenceCapture" ,
726
+ "-ResX=1280" ,
727
+ "-ResY=720" ,
728
+ "-ForceRes" ,
729
+ "-Windowed" ,
730
+ "-MovieCinematicMode=yes" ,
731
+ "-MovieFormat=Video" ,
732
+ "-MovieFrameRate=24" ,
733
+ "-MovieQuality=75" ,
734
+ "-NoTextureStreaming" ,
735
+ "-NoLoadingScreen" ,
736
+ "-NoScreenMessages" ,
737
+ ]
738
+
739
+ unreal .log (
740
+ "Sequencer command-line arguments: {}" .format (
741
+ " " .join (cmdline_args )
742
+ )
743
+ )
744
+
745
+ # Make a shallow copy of the current environment and clear some variables
746
+ run_env = copy .copy (os .environ )
747
+ # Prevent SG TK to try to bootstrap in the new process
748
+ if "UE_SHOTGUN_BOOTSTRAP" in run_env :
749
+ del run_env ["UE_SHOTGUN_BOOTSTRAP" ]
750
+
751
+ subprocess .call (cmdline_args , env = run_env )
743
752
744
753
return os .path .isfile (output_path ), output_path
745
754
@@ -773,6 +782,9 @@ def _unreal_render_sequence_with_movie_queue(self, output_path, unreal_map_path,
773
782
output_setting .output_resolution = unreal .IntPoint (1280 , 720 )
774
783
output_setting .file_name_format = movie_name
775
784
output_setting .override_existing_output = True # Overwrite existing files
785
+ # If needed we could enforce a frame rate, like for the Sequencer code.
786
+ # output_setting.output_frame_rate = unreal.FrameRate(24)
787
+ # output_setting.use_custom_frame_rate = True
776
788
# Remove problematic settings
777
789
for setting , reason in self ._check_render_settings (config ):
778
790
self .logger .warning ("Disabling %s: %s." % (setting .get_name (), reason ))
0 commit comments