Extend and control

This page shows how to drive the Viewer from code, react to its events, open locations with Viewer URLs, export screenshots, and extend the Viewer with your own UI and visualizations. To let an agent control the Viewer, see the Rerun MCP server.

Control playback and drive the Viewer from code

Configure playback in the blueprint

The time panel of the blueprint controls playback:

rr.send_blueprint(
    rrb.Blueprint(
        rrb.Spatial3DView(origin="/world"),
        rrb.TimePanel(
            timeline="frame",
            playback_speed=2.0,
            fps=30.0,
            loop_mode="all",
        ),
    )
)
ParameterMeaning
timelineThe active timeline.
playback_speedPlayback speed multiplier.
fpsFrames per second, for sequence timelines.
loop_mode"off", "selection", or "all". "selection" needs time_selection.
time_selectionA selected time range, as rrb.components.AbsoluteTimeRange(min, max).
state"expanded", "collapsed", or "hidden".

The time panel blueprint has no field for the play state or the position of the time cursor. To pause, play or start at a specific time, use one of the methods below.

Open a recording at a specific time

A Viewer URL can end with a #when= fragment that sets the time cursor, for example #when=frame@120. See Viewer URLs.

Drive a running Viewer from Python

rerun.experimental.ViewerClient connects to a running Viewer and controls it. This API is experimental and may change.

"""Open a recording in a running Viewer and move its time cursor."""

from rerun.experimental import ViewerClient

client = ViewerClient.connect()  # rerun+http://127.0.0.1:9876/proxy by default
client.open("recording.rrd")
client.set_time("frame", sequence=120, play_state="paused")
client.set_time(play_state="playing")
# The path is on the machine that runs the Viewer:
client.save_screenshot("viewer.png")
client.close("current")

Other useful methods:

  • ViewerClient.spawn(headless=True) starts a new Viewer, for example for screenshots in CI.
  • get_state() returns the open recordings, the time cursor, and the views.
  • get_selection() returns what the user has selected: entities and their instances, components, views, containers, and recordings.
  • take_screenshot() returns a PNG as bytes.
  • get_blueprint() and set_blueprint() read and replace the blueprint as a JSON-like dictionary.

In notebooks

The notebook Viewer has set_time_ctrl:

from rerun.notebook import Viewer

viewer = Viewer()
viewer.display()
viewer.set_time_ctrl(timeline="frame", sequence=120, play=True)

In an embedded web Viewer

The JavaScript WebViewer can control playback with setTime:

await viewer.setTime({ timeline: "frame", sequence: 42, playState: "playing" });

In the Viewer

  • Right-click in a time series view to move the time cursor to that time.
  • Press Space to play or pause.

Open a file in an already running Viewer

rerun recording.rrd sends the file to a Viewer that is already running on the default port, instead of starting a new one. To always start a new Viewer, use rerun --new recording.rrd (an alias for --port auto).

React to events in the Viewer

This section shows how to react to Viewer events, such as selection and time changes, and the alternatives where the Viewer cannot call back into your code.

Can I add buttons or sliders that call my Python script?

Not in the native Viewer. The native Viewer has no user-defined widgets (buttons, sliders, text fields), and it does not send events (such as selection changes) back to a Python logging script. See missing features.

Here is what you can do instead.

Callbacks in the web Viewer and in notebooks

We support registering callbacks to Viewer events, such as selection and time changes, in these environments:

In both cases, you can build your own widgets in the host page or notebook (for example with ipywidgets), and use them to control the Viewer.

Callbacks in Rust

For users extending the Viewer through the Rust re_viewer crate, there are two options:

Viewer URLs

A Viewer URL names a location in the Viewer, also called a route: a recording, a page, or something on a Rerun server. Opening a Viewer URL goes to that location.

URLLocation
about:recording?app_id=<APP_ID>&recording_id=<RECORDING_ID>A recording that is open in the Viewer
about:table?id=<TABLE_ID>A table that only exists in the Viewer
about:chunk_store?app_id=<APP_ID>&recording_id=<RECORDING_ID>The chunk store browser of an open recording
about:settingsThe settings page
rerun+http://<HOST>:<PORT>The catalog of a Rerun server
rerun+http://<HOST>:<PORT>/entry/<ENTRY_ID>A table or dataset on a Rerun server
rerun+http://<HOST>:<PORT>/dataset/<DATASET_ID>A dataset on a Rerun server
rerun+http://<HOST>:<PORT>/folder/<PATH>A folder of entries on a Rerun server

Query values are URL-encoded, so a recording with the application id my app has a URL like about:recording?app_id=my+app&recording_id=…. Use rerun+https:// for a server with TLS.

A dataset URL with a segment_id names a recording on a server. See Generate segment URLs in dataframes for those, and for the #when=… fragment that sets the time cursor.

In the web Viewer

The web Viewer shows its Viewer URL in the address bar, URL-encoded as the url query parameter of the page:

https://rerun.io/viewer?url=rerun%2Bhttp%3A%2F%2Flocalhost%3A51234%2Fentry%2F<ENTRY_ID>

Opening such a page opens the URL in its url parameter, and a page with several url parameters opens all of them. This makes the address bar a link to share, except for about:recording, about:chunk_store, and about:table: they name a recording or table by its id, and only work in a Viewer that already has it open.

Open a file by URL

The url parameter can also be an http:// or https:// URL of a file:

https://rerun.io/viewer?url=https%3A%2F%2Fexample.com%2Frecording.rrd

.rrd recordings and .rbl blueprints are streamed in as they download. Other file types that the Viewer can import are downloaded first, then loaded. Repeat the url parameter to open several files at once, for example a recording and its blueprint.

The native Viewer takes the same URLs as arguments: rerun https://example.com/recording.rrd.

Presigned and other URLs with a query string

URL-encode the file URL before you put it in the url parameter. A presigned S3 or GCS URL has its own ? and & characters. Without encoding, the Viewer page reads each &… as one of its own parameters, so they are cut from the file URL and the download fails:

from urllib.parse import quote

presigned = "https://my-bucket.s3.amazonaws.com/recording.rrd?X-Amz-Signature=…&X-Amz-Expires=3600"
viewer_url = "https://rerun.io/viewer?url=" + quote(presigned, safe="")

CORS

The web Viewer downloads the file from your browser, so the file host must allow cross-origin requests from the page that runs the Viewer. Set Access-Control-Allow-Origin on the file host to that origin:

  • https://rerun.io for https://rerun.io/viewer.
  • https://app.rerun.io if you embed app.rerun.io in an <iframe>, whatever the origin of the surrounding page.
  • The origin of your own page if you host the Viewer yourself. For S3 and GCS, this is the bucket's CORS configuration. The native Viewer does not need CORS.

This is for files. For a rerun+http:// connection to a gRPC server, see Connecting to a gRPC server from another origin.

Export screenshots, videos, and point clouds

Screenshot of a view in the Viewer

Right-click the title bar or tab of a view, or the view in the blueprint panel, and choose:

  • "Copy screenshot" to copy it to the clipboard, or
  • "Save screenshot…" to save it as a PNG file.

Copying screenshots is not supported in Safari and other WebKit browsers, including every browser on iOS.

Screenshots from Python

rerun.experimental.ViewerClient can take screenshots of a running Viewer. This API is experimental and may change.

"""Take screenshots of a running Viewer, as a file or as PNG bytes."""

from rerun.experimental import ViewerClient

client = ViewerClient.connect()

# Save a PNG file on the machine that runs the Viewer:
client.save_screenshot("viewer.png")

# Get a PNG as bytes, without writing a file:
png_bytes = client.take_screenshot(max_size=1024)

Both methods take an optional view_id to capture only one view. client.get_state().views lists the views and their IDs.

To take screenshots without a window, for example in CI, start a headless Viewer with ViewerClient.spawn(headless=True). This still needs a GPU or a software renderer.

Screenshots from the command line

rerun recording.rrd --new --screenshot-to screenshot.png --window-size 1920x1080

The Viewer opens the file, saves a screenshot of the whole window, and quits. --new starts a new Viewer. Without it, if a Viewer is already running, the command only sends the recording to that Viewer and saves no screenshot.

Export videos and point clouds

The Viewer cannot export a video of the playback, or export point clouds or meshes to files such as PLY. See missing features.

Workarounds:

  • To make a video, take a screenshot per time step with ViewerClient.set_time and save_screenshot, and combine the images with a tool such as ffmpeg. You can also use a screen recorder.
  • To export data, read it back with the dataframe API and write the file yourself, for example a PLY file with trimesh or open3d.

Implement custom visualizations (Rust only)

There are three ways to extend the Rerun Viewer with custom Rust code, depending on how deep you need to go: embedding custom UI panels alongside the Viewer, adding a custom visualizer to a built-in view, or implementing an entirely new view class.

Embedding custom UI in the Viewer

The Rerun Viewer, extended with a custom panel to the right

In the above screenshot you see the example extend_viewer_ui, which contains the Rerun Viewer to the left and a custom panel to the right. In this example the panel contains a hierarchical text view of the loaded data.

How to build it

The Rerun Viewer is defined by the crate re_viewer. It uses the Rust GUI library egui and its framework eframe. To extend the UI you need to create your own eframe application and embed re_viewer inside of it. You can then use egui to add custom panels and windows.

The best way to get started is by reading the source code of the extend_viewer_ui example.

To run your custom Viewer in a browser, compile it to WebAssembly. See Building for the web for how we build the Rerun web viewer.

To react to Viewer events (selection, time changes, …) from your own app, see the viewer_callbacks example and React to events in the Viewer.

Bevy and other game engines

There is no maintained Bevy integration. To visualize data from a Bevy app, log it with the Rust SDK like from any other Rust program. Revy is a proof-of-concept that snapshots the Bevy ECS into Rerun every frame.

Custom visualizers for built-in views

Rerun Viewer 3D view with a custom HeightField visualizer rendering a color-mapped terrain, its settings shown in the selection panel

You can register custom visualizers with existing built-in views (such as the 3D Spatial View) without having to implement an entire view class from scratch. This is the right approach when your data fits naturally into an existing view but needs custom rendering. A custom visualizer typically consists of a custom archetype, a visualizer system, and optionally a custom GPU renderer.

The custom_visualizer example demonstrates this by adding a GPU-rendered heightfield to the built-in 3D Spatial View. See its README for a detailed walkthrough of the three parts involved.

Custom view classes

The Rerun Viewer, extended with a custom View that is shown three times, each time showing points on a colored plane

If you need a completely new kind of view (not just a new visualizer within an existing view), you can implement a custom view class.

The custom_view example demonstrates how to add a fully custom View class to Rerun on startup. Views that are added this way have access to the exact same interfaces as all other Views, meaning that any of the built-in Views can serve as an additional example on how to implement Views.

The best way to get started is by reading the source code of the custom_view example.

Limitations

Extending the Viewer UI is only possible from Rust. You cannot embed your own GUI widgets inside existing views, and blueprints cannot add UI elements with callbacks. See #3087 for the state of Viewer extensibility.