Rendering film from moving camera in Replicator

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'

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):

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

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


Test1.usd (7.6 KB)

I have found the solution. For future forum users- you have to use:, start_timeline=True)

And instead of

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

You have to use:

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

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