Recording video#

This guide shows how to record mp4 clips from a visualizer or a scene sensor during a run.

Recorded clip of the Shadow Hand cube-reorientation task from the Newton visualizer

Each VideoRecorderCfg entry is independent: different sources write different files at their own cadence, with no limit on simultaneous recorders.

Quick Start#

Add a VideoRecorderCfg to env_cfg.video_recorders:

from isaaclab.envs.utils.video_recorder_cfg import VideoRecorderCfg

env_cfg.video_recorders = [
    VideoRecorderCfg(source="viz:newton", output_dir="videos/")
]

source also accepts an ImageViewCfg: use VideoRecorderCfg(source=view) to share an image selection and frame with a window. See Streaming a camera view in a visualizer for sensor and perspective examples.

Or pass --video [SOURCE] on the command line to record without editing the environment config. --video adds a single recorder; to record several sources at once, list one VideoRecorderCfg per source in env_cfg.video_recorders, which then takes precedence over the --video source (--video_length and --video_interval still apply to every recorder):

uv run isaaclab train --rl_library rsl_rl --task Isaac-Cartpole --video

--video records from the source it names, and --viz still decides which visualizers open a window. See the –video sources for every command-line form, and Sources and Clip control below for the VideoRecorderCfg options. To record from a different camera angle than the interactive view, see Recording from an independent camera angle.

Examples#

All three examples use the Shadow Hand cube-reorientation task, Isaac-Reorient-Cube-Shadow-Camera-Direct, which ships with a built-in tiled camera sensor. Examples 1 and 2 each demonstrate one recording source; Example 3 combines three sources.

The Newton RTX default records newton_viewport, tiled_camera_view and sensor clips. The deprecated Kit mode retains the original four streams and filenames, including kit_viewport and tiled_kit_viewport:

uv run --extra isaacsim --extra video python scripts/tutorials/07_visualizers/run_video_recording.py \
   --example 3 --num_envs 4 --viz kit,newton_gl

Pass --viz newton_gl to record an OpenGL viewport instead of the default Newton RTX viewport. The scene camera uses OVRTX by default. Install the ovrtx extra, or ov for both OvPhysX and OVRTX. The Newton viewport uses RTX by default, independently of the scene-camera recording. Use --viz newton_gl to select its lightweight OpenGL view.

Code for run_video_recording.py
  1# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
  2# All rights reserved.
  3#
  4# SPDX-License-Identifier: BSD-3-Clause
  5
  6"""Tutorial: recording video from visualizers and scene sensors.
  7
  8This script demonstrates three progressively richer recording configurations,
  9all using the Shadow Hand cube-reorientation task
 10(``Isaac-Reorient-Cube-Shadow-Camera-Direct``).
 11
 12Example 1 — Newton viewport (simplest)
 13    One clip from the Newton interactive viewport, showing 4 parallel environments.
 14
 15    .. code-block:: bash
 16
 17        uv run python scripts/tutorials/07_visualizers/run_video_recording.py \
 18            --example 1 --num_envs 4 --viz newton_rtx
 19
 20Example 2 — scene sensor only, headless
 21    One clip captured directly from the scene's tiled-camera sensor.
 22    No visualizer window opens; the sensor renders offline.
 23
 24    .. code-block:: bash
 25
 26        uv run python scripts/tutorials/07_visualizers/run_video_recording.py \
 27            --example 2 --num_envs 16
 28
 29Example 3 — Newton RTX viewport + tiled grid + scene sensor
 30    Three independent clip streams recorded simultaneously.
 31
 32    .. code-block:: bash
 33
 34        uv run python scripts/tutorials/07_visualizers/run_video_recording.py \
 35            --example 3 --num_envs 4 --viz newton_rtx
 36
 37Clips are written to ``videos/recording_tutorial/example_<N>/`` in the working directory.
 38Examples 1 and 2 each demonstrate one recording source; Example 3 combines all of them.
 39``--viz`` selects the visualizers to record from; the configs below only set their camera and panels.
 40"""
 41
 42from __future__ import annotations
 43
 44import argparse
 45import contextlib
 46import os
 47import sys
 48
 49import gymnasium as gym
 50import torch
 51
 52from isaaclab.visualizers import ImageViewCfg, VisualizerCfg, WindowCfg
 53
 54import isaaclab_tasks  # noqa: F401
 55
 56with contextlib.suppress(ImportError):
 57    import isaaclab_tasks_experimental  # noqa: F401
 58
 59from isaaclab.app import add_launcher_args, launch_simulation
 60from isaaclab.envs.utils.video_recorder_cfg import VideoRecorderCfg
 61
 62from isaaclab_tasks.utils import resolve_task_config, setup_preset_cli
 63
 64# ---------------------------------------------------------------------------
 65# Constants
 66# ---------------------------------------------------------------------------
 67
 68_VIDEO_LENGTH = 100  # env steps per clip
 69_NUM_STEPS = 115  # slightly more than _VIDEO_LENGTH so the clip flushes cleanly
 70
 71_TASK_SHADOW = "Isaac-Reorient-Cube-Shadow-Camera-Direct"
 72
 73# Viewport camera: positioned to show a 2×2 grid of Shadow Hand environments.
 74# env_spacing=1.0 with 4 envs → envs centered at ±0.5 in x and y.
 75# Cube spawns at ~(0, -0.39, 0.6) per env; wrist cylinder is the landmark at the top.
 76_SHADOW_EYE = (0.0, -2.2, 1.8)
 77_SHADOW_LOOKAT = (0.0, -0.1, 0.4)
 78_SHADOW_ENV_SPACING = 1.0
 79
 80# Skip the first few steps so the scene has settled before recording starts.
 81_RENDER_STEP_OFFSET = 5
 82
 83
 84def _output_dir(example: int) -> str:
 85    return os.path.join("videos", "recording_tutorial", f"example_{example}")
 86
 87
 88def _shadow_env_cfg(num_envs: int, env_spacing: float = _SHADOW_ENV_SPACING):
 89    """Build a base Shadow Hand camera env cfg shared by all examples."""
 90    overrides = list(sys.argv[1:])
 91    if not any(arg.startswith("renderer=") for arg in overrides):
 92        overrides.append("renderer=rtx")
 93    env_cfg, _ = resolve_task_config(_TASK_SHADOW, "", overrides=(*overrides, "env.scene.tiled_camera=rgb"))
 94    env_cfg.scene.tiled_camera.height = 256
 95    env_cfg.scene.tiled_camera.width = 256
 96    env_cfg.scene.num_envs = num_envs
 97    env_cfg.scene.env_spacing = env_spacing
 98    return env_cfg
 99
100
101# ---------------------------------------------------------------------------
102# Per-example environment config builders
103# ---------------------------------------------------------------------------
104
105
106def _build_env_cfg_example_1(num_envs: int, legacy_kit: bool = False):
107    """Shadow Hand + Newton viewport: one clip from the interactive viewport."""
108    from isaaclab_visualizers.kit import KitBackendCfg
109    from isaaclab_visualizers.newton import NewtonGLBackendCfg
110
111    env_cfg = _shadow_env_cfg(num_envs)
112    env_cfg.sim.visualizer_cfgs = [
113        VisualizerCfg(
114            eye=_SHADOW_EYE,
115            lookat=_SHADOW_LOOKAT,
116            backend=KitBackendCfg() if legacy_kit else NewtonGLBackendCfg(initial_renderer="rtx"),
117        )
118    ]
119
120    out = _output_dir(1)
121    env_cfg.video_recorders = [
122        VideoRecorderCfg(
123            source="viz:kit" if legacy_kit else "viz:newton",
124            output_dir=out,
125            output_filename_prefix="kit_viewport" if legacy_kit else "newton_viewport",
126            video_length=_VIDEO_LENGTH,
127            fps=30,
128            step_offset=_RENDER_STEP_OFFSET,
129        ),
130    ]
131    return env_cfg, _TASK_SHADOW
132
133
134def _build_env_cfg_example_2(num_envs: int):
135    """Shadow Hand + headless: scene tiled-camera sensor clip only."""
136    env_cfg = _shadow_env_cfg(num_envs, env_spacing=2.0)
137
138    out = _output_dir(2)
139    env_cfg.video_recorders = [
140        VideoRecorderCfg(
141            source="sensor:tiled_camera",
142            output_dir=out,
143            output_filename_prefix="sensor",
144            video_length=_VIDEO_LENGTH,
145            fps=30,
146        ),
147    ]
148    return env_cfg, _TASK_SHADOW
149
150
151def _build_env_cfg_example_3(num_envs: int, legacy_kit: bool = False):
152    """Record the Newton RTX view, a tiled scene-camera view, and one sensor image together."""
153    from isaaclab_visualizers.kit import KitBackendCfg
154    from isaaclab_visualizers.newton import NewtonGLBackendCfg
155
156    env_cfg = _shadow_env_cfg(num_envs)
157    tiled_view = ImageViewCfg(source="tiled_camera", envs=tuple(range(min(num_envs, 16))))
158    env_cfg.sim.visualizer_cfgs = [
159        VisualizerCfg(
160            eye=_SHADOW_EYE,
161            lookat=_SHADOW_LOOKAT,
162            streaming_view=True,
163            streaming_envs=min(num_envs, 16),
164            window=WindowCfg(size=(1280, 720)),
165            focal_length=25.0,
166            backend=NewtonGLBackendCfg(initial_renderer="rtx"),
167        )
168    ]
169    streams = [
170        ("viz:newton", "newton_viewport", _RENDER_STEP_OFFSET),
171        (tiled_view, "tiled_camera_view", _RENDER_STEP_OFFSET),
172        ("sensor:tiled_camera", "sensor", 0),
173    ]
174    if legacy_kit:
175        # Keep the original four streams and filenames for explicitly requested Kit runs.
176        newton_view = env_cfg.sim.visualizer_cfgs[0].replace(streaming_view=False, backend=NewtonGLBackendCfg())
177        env_cfg.sim.visualizer_cfgs = [
178            VisualizerCfg(
179                eye=_SHADOW_EYE,
180                lookat=_SHADOW_LOOKAT,
181                streaming_view=True,
182                streaming_envs=min(num_envs, 16),
183                backend=KitBackendCfg(),
184            ),
185            newton_view,
186        ]
187        streams = [
188            ("viz:kit", "kit_viewport", _RENDER_STEP_OFFSET),
189            ("viz:kit:streaming_view", "tiled_kit_viewport", _RENDER_STEP_OFFSET),
190            ("viz:newton", "newton_viewport", 0),
191            ("sensor:tiled_camera", "sensor", 0),
192        ]
193    env_cfg.video_recorders = [
194        VideoRecorderCfg(
195            source=source,
196            output_dir=_output_dir(3),
197            output_filename_prefix=prefix,
198            video_length=_VIDEO_LENGTH,
199            fps=30,
200            step_offset=offset,
201        )
202        for source, prefix, offset in streams
203    ]
204    return env_cfg, _TASK_SHADOW
205
206
207_BUILDERS = {
208    1: _build_env_cfg_example_1,
209    2: _build_env_cfg_example_2,
210    3: _build_env_cfg_example_3,
211}
212
213# ---------------------------------------------------------------------------
214# Argument parsing
215# ---------------------------------------------------------------------------
216parser = argparse.ArgumentParser(description="Video recording tutorial for Isaac Lab environments.")
217parser.add_argument(
218    "--example", type=int, default=1, choices=[1, 2, 3], help="Which recording example to run (1, 2, or 3)."
219)
220parser.add_argument("--num_envs", type=int, default=None, help="Number of environments to simulate.")
221add_launcher_args(parser)
222args_cli, hydra_args = setup_preset_cli(parser)
223sys.argv = [sys.argv[0]] + hydra_args
224
225
226def main():
227    """Run the selected video recording example."""
228    defaults = {1: 4, 2: 16, 3: 4}
229    num_envs = args_cli.num_envs if args_cli.num_envs is not None else defaults[args_cli.example]
230    visualizers = next((arg.split("=", 1)[1].split(",") for arg in hydra_args if arg.startswith("visualizer=")), None)
231    if args_cli.example == 2:
232        env_cfg, task = _BUILDERS[args_cli.example](num_envs)
233    else:
234        env_cfg, task = _BUILDERS[args_cli.example](num_envs, legacy_kit=bool(visualizers and "kit" in visualizers))
235    env_cfg.sim.device = args_cli.device if args_cli.device is not None else env_cfg.sim.device
236
237    # The builders configure recording views after task resolution. Reapply the requested
238    # visualizer selection, including newton_rtx and none, when launching those views.
239    with launch_simulation(env_cfg, {**vars(args_cli), "visualizer": visualizers}):
240        env = gym.make(task, cfg=env_cfg)
241
242        out = _output_dir(args_cli.example)
243        print(f"[INFO]: Running Example {args_cli.example} — clips → {out}/")
244        print(f"[INFO]: Gym observation space: {env.observation_space}")
245        print(f"[INFO]: Gym action space: {env.action_space}")
246
247        print("[INFO]: Setup complete.")
248        env.reset()
249        for _ in range(_NUM_STEPS):
250            with torch.inference_mode():
251                actions = 2 * torch.rand(env.action_space.shape, device=env.unwrapped.device) - 1
252                env.step(actions)
253
254        env.close()
255        print(f"[INFO]: Done. Clips written to {out}/")
256
257
258if __name__ == "__main__":
259    main()

Example 1: Newton viewport#

uv run python scripts/tutorials/07_visualizers/run_video_recording.py \
    --example 1 --num_envs 4 --viz newton_rtx
  • Records the Newton interactive viewport using RTX

  • Shows 4 parallel environments

  • One clip is written to videos/recording_tutorial/example_1/newton_viewport_0000.mp4

Newton visualizer (OpenGL recording; the example now defaults to RTX)

Example 2: Scene sensor, headless#

uv run python scripts/tutorials/07_visualizers/run_video_recording.py \
    --example 2 --num_envs 16

Scene sensor

  • No visualizer window opens; frames are read directly from the tiled_camera sensor

  • One clip is written to videos/recording_tutorial/example_2/sensor_0000.mp4

  • source="sensor:tiled_camera" is the key under which the camera is registered in env.scene.sensors

  • The sensor must have the recorded channel in its data_types; rgb is the default, and depth, segmentation, and normals are also available (see Sources)

Example 3: All sources simultaneously#

uv run python scripts/tutorials/07_visualizers/run_video_recording.py \
    --example 3 --num_envs 4 --viz newton_rtx

Three independent clips are written to videos/recording_tutorial/example_3/:

  • newton_viewport_0000.mp4: Newton viewport showing its OVRTX camera

  • tiled_camera_view_0000.mp4: an ImageViewCfg composing the scene camera’s per-environment images

  • sensor_0000.mp4: scene tiled-camera sensor (offline render)

RTX viewport recording uses the OVRTX runtime and works with Newton or OvPhysX physics. Set the visualizer’s headless=True to record without opening a window. The tiled ImageViewCfg and scene sensor remain independent recording sources while the main viewport shows RTX. Naming the scene camera in the image view fixes the recorded source even if the window switches to another camera.

Recipes#

The recipes below are command-line and configuration snippets that are not part of the tutorial script.

Recording during RL training#

Record a short clip at regular intervals while training, without opening a window:

uv run isaaclab train --rl_library rsl_rl --task Isaac-Cartpole --video \
    --video_length 200 --video_interval 2000

With no --viz, --video records from a headless Newton visualizer. This writes a 200-step clip every 2,000 steps. The train and play entrypoints put clips in videos/ under the run’s log directory unless a recorder sets output_dir; a script that builds its own recorders writes to output_dir (default videos). Add --viz newton_rtx to watch and record an RTX viewport with Newton or OvPhysX physics.

Recording depth or segmentation from a scene sensor#

Append a channel to the sensor source to record something other than RGB. Each recorder writes its own file, so several channels of one camera can be recorded in the same run:

env_cfg.video_recorders = [
    VideoRecorderCfg(source="sensor:tiled_camera:rgb", output_filename_prefix="rgb"),
    VideoRecorderCfg(source="sensor:tiled_camera:depth", output_filename_prefix="depth"),
]

Depth uses the turbo colormap over depth_colormap_min to depth_colormap_max. Use the same prefix-per-recorder pattern for segmentation and normals.

Recording while streaming with Viser or Rerun#

Viser and Rerun stream to a browser or viewer and have no frame capture, so they cannot be recorded. Pair them with a capture-capable visualizer that runs headless next to them:

uv run isaaclab train --rl_library rsl_rl --task Isaac-Cartpole --viz viser --video viz:newton

Alternatively, record directly from a scene camera with source="sensor:<name>", which needs no visualizer.

Recording from an independent camera angle#

Configure a separate perspective view for the recording alongside the interactive Newton window. The recorder identifies its producer through the shared ImageViewCfg:

from isaaclab_visualizers.newton import NewtonGLBackendCfg

from isaaclab.visualizers import ImageViewCfg, PerspectiveCameraCfg, VisualizerCfg

recording_view = ImageViewCfg(source=PerspectiveCameraCfg(eye=(12.0, 0.0, 6.0)))
env_cfg.sim.visualizer_cfgs = [
    VisualizerCfg(eye=(4.0, 4.0, 2.0), backend=NewtonGLBackendCfg(initial_renderer="rtx")),
    VisualizerCfg(view=recording_view, headless=True, backend=NewtonGLBackendCfg()),
]
env_cfg.video_recorders = [
    VideoRecorderCfg(source=recording_view, output_dir="videos/"),
]

Alternatively, use a CameraCfg sensor in the scene and record with source="sensor:<name>", which gives full control over the recording viewpoint without requiring a second interactive visualizer.

Sources#

The source string selects what to capture:

Source string

Captures from

"viz" (default)

First capture-capable visualizer --viz selected, else a headless Newton visualizer

"viz:kit"

Kit visualizer viewport

"viz:kit:streaming_view"

Kit streaming camera panel, requires streaming_view=True

"viz:newton"

Newton visualizer viewport, in whichever renderer the window shows (OpenGL or RTX)

"viz:newton:streaming_view"

Newton streaming camera panel, requires streaming_view=True

"sensor:<name>"

env.scene.sensors[name], RGB (default)

"sensor:<name>:rgb"

RGB channel

"sensor:<name>:depth"

Depth, turbo colormap, range depth_colormap_min … depth_colormap_max

"sensor:<name>:segmentation"

Segmentation, colorized

"sensor:<name>:normals"

Surface normals, colorized

The camera angle, resolution, and other visualizer settings are configured on the corresponding visualizer config, not on the recorder. A viz:<type> visualizer that --viz does not select runs headless, only for the recording, with the settings of its config in sim.visualizer_cfgs.

visualizer is accepted as the long form of the viz prefix ("visualizer:kit" is "viz:kit"). The newton_gl type ("viz:newton_gl") is still accepted as an alias for newton. Bare visualizer types are accepted here too, e.g. VideoRecorderCfg(source="newton") is equivalent to VideoRecorderCfg(source="viz:newton").

Note

Use NewtonGLBackendCfg(initial_renderer="rtx") to record the RTX viewport, including headless runs. The recorder source remains "viz:newton"; newton_rtx selects the renderer when launching the visualizer.

Clip control#

Field

Default

Meaning

video_length

200

Env steps per clip

video_interval

0

0 = one clip starting at step 1; N > 0 = new clip every N steps

fps

None

Output frame rate; None resolves from env.metadata["render_fps"] or 1 / step_dt

output_dir

"videos"

Directory for output files (created on demand)

output_filename_prefix

"clip"

File stem; output is <prefix>_NNNN.mp4

keep_last_n_clips

None

Delete older clips; None keeps all

One clip at the start of a run:

VideoRecorderCfg(source="viz:newton", video_length=500, video_interval=0)

Recurring clips every 1,000 env steps:

VideoRecorderCfg(source="viz:newton", video_length=200, video_interval=1000)

Keep only the most recent clip on disk:

VideoRecorderCfg(source="viz:newton", video_length=200, video_interval=1000,
                 keep_last_n_clips=1)

Limitations#

  • source="viz:newton:streaming_view" and source="viz:kit:streaming_view" require streaming_view=True on the corresponding visualizer cfg. A RuntimeError is raised when the recorder is constructed if it is not set.

  • For source="sensor:<name>", the named sensor must exist on the scene config with the recorded channel ("rgb" by default) in its data_types.

Visualizer

--video

Notes

kit

✓

Launches Isaac Sim; the launch enables camera rendering for the recording.

newton

✓

Uses pyglet’s EGL backend when headless; the default for --video without a capture-capable --viz.

rerun

✗

Remote streaming tool; no local frame-capture API. viz:rerun is an error; --video --viz rerun records from a headless newton.

viser

✗

Browser streaming tool; no local frame-capture API. viz:viser is an error; --video --viz viser records from a headless newton.

To record video while streaming with Rerun or Viser, see Recording while streaming with Viser or Rerun.

See also#