Video Recording

Open in ClaudeOpen in ChatGPT

The ZED SDK allows you to record large video datasets using H.264, H.265 or lossless compression. The ZED SDK uses StereoLabs’ SVO format to store videos along with additional metadata such as timestamps and sensor data.

When loading SVO files, the ZED API will behave as if a ZED was connected and a live feed was available. Every module of the ZED API will be available: depth, tracking, spatial mapping and more. To record SVO videos, you can use the ZED Explorer application in GUI or command-line mode or build your own recording app using the ZED API.

Compression Modes

SVO videos can be recorded using various compression modes. We provide both lossless and compressed modes to preserve image quality or reduce file size.

Compression ModeAverage Size (% of RAW)
LOSSLESS (PNG/ZSTD)42%
H.264 (AVCHD)1%
H.265 (HEVC)1%
H.264 LOSSLESS25%
H.265 LOSSLESS25%

Benefits of Hardware Encoding

For optimal performance, we recommend using the H.264 and H.265 recording modes. They have been designed to use the hardware-based encoder (referred to as NVENC) built into NVIDIA® graphics cards. With encoding offloaded to NVENC, the GPU and the CPU are free for other operations. For example, in a compute-heavy scenario, it is now possible to record video at a full frame rate with minimal impact on the main application.

Encoding Quality

At a given bitrate, hardware encoding quality can vary depending on your GPU generation. The updated NVENC encoder on Turing-based NVIDIA® GPUs (RTX 20-Series, Jetson™ Xavier) will typically produce superior quality than encoders on older generation GPUs (GTX 10-Series, Jetson™ Nano).

Using SVO2

In release 4.1 of the ZED SDK was introduced the SVO2 file format, designed to store high-frequency data from the camera, and introduce the ability to record custom data in order to store data from external sensors. This recording format is enabled by default in the ZED SDK starting from version 4.1.

  • High-frequency data: SVO(1) files would previously only record sensor data at the camera’s image frame rate (15-120 Hz). With SVO2, sensors are recorded at their respective frequency, enabling all ZED SDK algorithms which use high-frequency data, for example the Positional Tracking Gen 2.
  • Custom Data: the SVO2 format exposes methods to record custom data. This data can be anything defined by the user, from metadata to label the specific SVO sequence, to data from external sensors, such as IMU, GPS, etc. All custom data is timestamped to be read alongside the original ZED data. More information on the Custom Data API here: C++ / Python / C# / C.

Please check out the custom data Recording and Playback samples on GitHub for more information.

Recording with Multiple Cameras

You can record videos with multiple cameras connected to the same PC. When using hardware encoding (H.264, H.265), make sure to check the NVENC support matrix or Jetson one which shows the maximum number of concurrent recording sessions that can be started on a single NVIDIA® GPU. You can also add multiple GPUs in a single server to increase the number of recording sessions with hardware encoding.

Using the Recording API

Video Recording

To record SVO files, you need to enable the Recording module with enableRecording(). Specify an output file name (eg: output.svo) and SVO_COMPRESSION_MODE, then save each grabbed frame. SVO lets you record video and associated metadata (timestamp, IMU data and more if available).

1// Create a ZED camera object
2Camera zed;
3
4// Enable recording with the filename specified in argument
5String output_path(argv[1]);
6RecordingParameters recordingParameters;
7recordingParameters.compression_mode = SVO_COMPRESSION_MODE::H264;
8recordingParameters.video_filename = output_path;
9err = zed.enableRecording(recordingParameters);
10
11while (!exit_app) {
12 // Each new frame is added to the SVO file
13 zed.grab();
14}
15// Disable recording
16zed.disableRecording();

Video Playback

To play SVO files, simply add the file path as an argument in setFromSVOFile(). When loading SVO files, the ZED API will behave as if a ZED was connected and a live feed was available. Every module of the ZED API will be available: depth, tracking, spatial mapping and more. When an SVO file is read entirely, END_OF_SVOFILE_REACHED error code is returned.

1// Create a ZED camera object
2Camera zed;
3
4// Set SVO path for playback
5String input_path(argv[1]);
6InitParameters init_parameters;
7init_parameters.input.setFromSVOFile(input_path);
8
9// Open the ZED
10err = zed.open(init_parameters);
11
12sl::Mat svo_image;
13while (!exit_app) {
14 if (zed.grab() == ERROR_CODE::SUCCESS) {
15 // Read side by side frames stored in the SVO
16 zed.retrieveImage(svo_image, VIEW::SIDE_BY_SIDE);
17 // Get frame count
18 int svo_position = zed.getSVOPosition();
19 }
20 else if (zed.grab() == END_OF_SVOFILE_REACHED) {
21 std::cout << "SVO end has been reached. Looping back to first frame" << std::endl;
22 zed.setSVOPosition(0);
23 }
24}

Code Example

Check out the SVO Recording, SVO Playback and SVO Export samples on GitHub.