Hello,
I’m trying to render a cinematic from three cameras perspective. I want to automate the rendering process so I’m using Python. What I do is duplicate twice the original cinematic. Then I set the ‘camera_binding_id’ for each cinematic to one of the three cameras so each cinematics is rendered from a different perspective than the other two.
import unreal
def render_sequence():
camera_bindings_list=[]
#load a cinematic and duplicate it
level_sequence_1 = unreal.load_asset("/Game/Cinematics/Takes/2023-06-26/Scene_1_01")
level_sequence_2 = unreal.EditorAssetLibrary.duplicate_loaded_asset(level_sequence_1, "/Game/Cinematics/Takes/2023-06-26/Scene_1_07")
level_sequence_3 = unreal.EditorAssetLibrary.duplicate_loaded_asset(level_sequence_1, "/Game/Cinematics/Takes/2023-06-26/Scene_1_08")
#going through the first cinematic to get all camera bindings
for master in level_sequence_1.find_master_tracks_by_type(unreal.MovieSceneTrack):
if master.get_class().get_name()=="MovieSceneSubTrack":
for section in master.get_sections():
for binding in section.get_sequence().get_bindings():
try:
#I'm only interrested in bindings that are camera. All my camera are of the class "BlueprintGeneratedClass"
if binding.get_possessed_object_class().get_class().get_fname() == "BlueprintGeneratedClass":
#saving the three camera binding id in a list
camera_bindings_list.append(binding.get_binding_id())
except:
pass
#This function set the given the sequence camera cut track camera_binding_id with the given camera_binding ID
setting_main_camera(level_sequence_1, camera_bindings_list[0])
unreal.EditorAssetLibrary.save_asset("/Game/Cinematics/Takes/2023-06-26/Scene_1_01", only_if_is_dirty=True)
setting_main_camera(level_sequence_2, camera_bindings_list[1])
unreal.EditorAssetLibrary.save_asset("/Game/Cinematics/Takes/2023-06-26/Scene_1_07", only_if_is_dirty=True)
setting_main_camera(level_sequence_3, camera_bindings_list[2])
unreal.EditorAssetLibrary.save_asset("/Game/Cinematics/Takes/2023-06-26/Scene_1_08", only_if_is_dirty=True)
def setting_main_camera(level_sequence, binding, asset_path):
for master in level_sequence.find_master_tracks_by_type(unreal.MovieSceneTrack):
if master.get_class().get_name()=="MovieSceneCameraCutTrack":
for section in master.get_sections():
section.set_editor_property('camera_binding_id', binding)
When I execute the code there are no warnings or errors raised. However when I take a look in the sequencer at the camera cut track camera_binding_id it says that “the specified binding could not be located in the sequence”. So when I render such a sequence it will use the ‘player start perspective’ as the main camera.
I also made a short python function that print of screen all camera binding ID of a given level sequence. Everytime I execute it with a cinematic that has no camera bind to its camera cut tracks - according to the sequencer - it prints a camera binding ID for the camera cut tracks that is the exact same as one of the camera binding IDs from one of the camera tracks
import unreal
level_sequence = level_sequence_1 = unreal.load_asset("/Game/Cinematics/Takes/2023-06-26/Scene_1_01")$
#Going through all sub sequence of the level sequence
for master in level_sequence.find_master_tracks_by_type(unreal.MovieSceneTrack):
#first i'll go through "MovieSceneSubTrack" sequences
if master.get_class().get_name()=="MovieSceneSubTrack":
for section in master.get_sections():
for binding in section.get_sequence().get_bindings():
try:
#I'm only interrested in bindings that are camera. All my camera are of the class "BlueprintGeneratedClass"
if binding.get_possessed_object_class().get_class().get_fname() == "BlueprintGeneratedClass":
print("Camera ID")
print(binding.get_binding_id().get_editor_property('Guid').to_string())
except:
pass
# Then I'll go through "MovieSceneCameraCutTrack" and print the camera binding ID
if master.get_class().get_name()=="MovieSceneCameraCutTrack":
for section in master.get_sections():
print("Camera binding ID")
print(section.get_camera_binding_id().get_editor_property('Guid').to_string())
So do you guys have any idea where this error might come from? Am I missing something with how binding_ids work?