cgv_record_start: Start Recording the Viewer to a Video File

View source: R/record.R

cgv_record_startR Documentation

Start Recording the Viewer to a Video File

Description

Pipes raw RGB frames from the live canvas into ffmpeg, which encodes them on the fly. The recording runs in the background while the user keeps interacting with the viewer (mouse, keyboard).

Usage

cgv_record_start(
  viewer,
  file,
  fps = 30L,
  duration = NA_real_,
  ffmpeg_args = NULL
)

Arguments

viewer

External pointer from cgv_viewer(). The window must already be running (call this from a frame callback, or after cgv_run() has built the canvas — typically by setting a duration and starting recording before cgv_run()).

file

Output path; extension determines the format.

fps

Frames per second (default 30).

duration

Optional cap in seconds; NA = unlimited.

ffmpeg_args

Optional extra ffmpeg flags spliced before the output path (e.g. "-c:v libvpx-vp9 -b:v 2M"). NULL = use defaults (libx264, yuv420p, veryfast).

Details

Requires ffmpeg on PATH. The container/codec is chosen by the file extension (.mp4 / .mkv / .webm / etc.). Frames are captured at the requested fps; if the rendering loop produces frames faster, extras are dropped.

The recording is automatically stopped when the viewer is closed, cgv_record_stop() is called, or the optional duration elapses.

Value

No return value, called for side effects: stores the recording parameters on the viewer; the ffmpeg pipe is opened lazily on the first rendered frame. Returns NULL invisibly.


cgvR documentation built on May 12, 2026, 1:06 a.m.