Rendering film from moving camera in Replicator

Hi,
I have a camera with predefined path, in USD format. When I run timeline in USD Composer, it moves correctly and saves the mp4 film correctly (with use of Movie Capture extension). Now I want to do the same in Replicator script, but the camera does not move at all. My main focus is to run this script headlessly, but right now it doesn’t work in Code UI. The question is- how to move camera every frame?

Here is the script that I use:

import omni.replicator.core as rep
import omni.usd

scene_file = R'Path/To/Test\Test1.usd'
omni.usd.get_context().open_stage(scene_file)


with rep.new_layer():
    camera0_path = '/World/Camera'
    camera_paths = [camera0_path]
    render_products = [rep.create.render_product(camera_path, (1920,1080)) for camera_path in camera_paths]

    with rep.trigger.on_frame(num_frames=20, rt_subframes=32):
        pass

    writer = rep.WriterRegistry.get("BasicWriter")

    writer.initialize(output_dir=R"path/to/output", rgb=True, distance_to_camera=True, distance_to_image_plane=True)

    writer.attach(render_products)

    rep.orchestrator.run(num_frames=20)

Test1.usd (7.6 KB)

I have found the solution. For future forum users- you have to use:

rep.orchestrator.run(num_frames=20, start_timeline=True)

And instead of

with rep.trigger.on_frame(num_frames=20):
        pass

You have to use:

with rep.trigger.on_time(interval=X):
        pass

Where the interval has to be NumberOfFrames/Framerate. It works for me and saves everything correctly.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.