Unable to execute MoviePipelineQueue from Python

I’ve done something similar with take_high_res_screenshot, in case that’s helpful. This code will take a screenshot from the point of view of “CameraOne”. It does fine on all the frames except the first one, so I added a bogus frame at the start of the level sequence (frame -1).

Note that the settings for high res screenshots are very persistent. If the quality is too low, you might look at the options (hidden under the three-bar menu in the upper left of the viewport).

I’m sure this is inelegant – I don’t really do this sort of event-based programming – but it works for me.

import unreal
import time


class Capture(object):
    """ Register a function and run it on tick, """

    def __init__(self, fileprefix="test_", frames=range(-1, 50)):
        self.fileprefix = fileprefix
        LES = unreal.get_editor_subsystem(unreal.LevelEditorSubsystem)
        LES.editor_set_game_view(True)
        EAS = unreal.get_editor_subsystem(unreal.EditorActorSubsystem)
        actors = EAS.get_all_level_actors()

        self.cameraActor = unreal.EditorFilterLibrary.by_actor_label(actors, "CameraOne")[0]
        # make a generator function so we can call next on it,
        self.frames = frames
        self.frameIter = iter(self.frames)
        self.tickcount = 0
        self.shotName = "warmup.png"
        self.theFrame = next(self.frameIter)

        print("setting frame")
        print("frame is " + str(self.theFrame))
        unreal.LevelSequenceEditorBlueprintLibrary.set_current_time(self.theFrame)
        print("capture, self.tickcount=" + str(self.tickcount) + "  :t=" + str(self.theFrame))
        time.sleep(4)

        # make a file name with a 4 digit frame number
        self.shotName = self.fileprefix + str(self.theFrame).zfill(4) + ".png"
        self.captureTask = unreal.AutomationLibrary.take_high_res_screenshot(
            1920,
            1080,
            self.shotName,
            camera=self.cameraActor,
            capture_hdr=True,
            delay=0.25
        )

        # register a callback on pretick
        self.on_pre_tick = unreal.register_slate_pre_tick_callback(self.__pretick__)

    def __pretick__(self, deltatime):
        """ Function we will call every pretick, """

        if self.captureTask.is_task_done():
            try:
                # Count
                self.tickcount = self.tickcount + 1

                # Get the next frame from our generator function
                self.theFrame = next(self.frameIter)
                print("setting frame")
                print("frame is " + str(self.theFrame))
                self.shotName = self.fileprefix + str(self.theFrame).zfill(4) + ".png"

                unreal.LevelSequenceEditorBlueprintLibrary.set_current_time(self.theFrame)
                time.sleep(2)

                print("capture, self.tickcount=" + str(self.tickcount) + "  :t=" + str(self.theFrame))

                self.captureTask = unreal.AutomationLibrary.take_high_res_screenshot(
                        1920,
                        1080,
                        # actor.get_name() + ".hdr",
                        self.shotName,
                        camera=self.cameraActor,
                        capture_hdr=True
                    )

            except Exception as error:
                print(error)
                unreal.unregister_slate_pre_tick_callback(self.on_pre_tick)


if __name__ == '__main__':
        instance = Capture()