Simultaneous Streaming and SVO Recording with ZED X MINI

Hi Stereolabs.

What would be the best and most secure approach to simultaneously stream and store video from a ZED X MINI camera?

Specifically, I would like to:

  1. Stream the RGB feed from one of the ZED X MINI cameras via RTSP(or whatever), so it can be viewed in a web browser.
  2. Record and store the video in SVO format for later processing using deep learning models.

Both processes need to run continuously over extended periods, so reliability and stability are crucial.

Thank you in advance for your support.

Best regards,
Jiseong Heo

Hi @jsheo96

You could use GStreamer or the Local Streaming module of the ZED SDK

In this case, you can use ZED Explorer:

  • create a local streaming server
  • start the SVO recording
    Now you can use the local streaming to create a receiver and view the camera stream (ZED Explorer or ZED Depth Viewer), you can use GStreamer (see parameters input-stream-ip and input-stream-port), or any other type of stream receiver.
1 Like

Hi,

I tried the approach you suggested.
However, I encountered an issue: the SVO file gets corrupted when I run either GStreamer or the local streaming receiver at the same time as the SVO recording.

The corrupted section of the SVO file is shown below:


Hopefully, you can find the area of the corruption. The below area is corrupted.

Below is the code I used to enable both recording and streaming simultaneously.

import pyzed.sl as sl
import time

def main():
    zed = sl.Camera()

    init_params = sl.InitParameters()
    # init_params.camera_resolution = sl.RESOLUTION.HD1080
    # init_params.camera_fps = 15

    if zed.open(init_params) != sl.ERROR_CODE.SUCCESS:
        print("Failed to open ZED camera")
        exit(1)

    # Start recording to SVO
    recording_params = sl.RecordingParameters("output.svo", sl.SVO_COMPRESSION_MODE.H264)
    if zed.enable_recording(recording_params) != sl.ERROR_CODE.SUCCESS:
        print("Failed to start SVO recording")
        zed.close()
        exit(1)

    # Enable streaming to network (default port 30000)
    stream_params = sl.StreamingParameters()
    stream_params.codec = sl.STREAMING_CODEC.H264  # or H265
    if zed.enable_streaming(stream_params) != sl.ERROR_CODE.SUCCESS:
        print("Failed to enable streaming")
        zed.disable_recording()
        zed.close()
        exit(1)

    print("Streaming and recording started. Press Ctrl+C to stop.")

    start_time = time.time()
    try:
        while True:
            if zed.grab() == sl.ERROR_CODE.SUCCESS:
                pass  # You can still retrieve frames here if you want
    except KeyboardInterrupt:
        print("\nStopping...")

    zed.disable_streaming()
    zed.disable_recording()
    zed.close()

if __name__ == "__main__":
    main()

and the reciever side, I simply tried the sample zed python code.

cd /usr/local/zed/samples/camera streaming/reciever/python/
python streaming_reciever.py --ip_address 127.0.0.1:30000

I also tried gstreamer code too

gst-launch-1.0 zedsrc input-stream-ip=127.0.0.1 input-stream-port=30000 ! queue ! autovideoconvert ! queue ! fpsdisplaysink

The results were the same (corrupted svo)

Could you help identify what might be causing the corruption and how to resolve it?
Thanks in advance for your support.

Best regards,
Jiseong

This is a typical frame-tearing issue with a USB 3 camera.
It’s caused by a buffer overflow in the USB 3 controller because the CPU is overloaded, and it cannot retrieve the data fast enough.

What’s the host type?

1 Like

Thank you for the quick reply.

We are currently using the ZED 2i camera.
Our host PC has sufficient computing resources — a workstation equipped with a 32-core CPU, 128 GB RAM, and external GPUs (RTX 4090).

We are planning to switch to the ZED X MINI along with the ZED Box MINI.
If the issue is due to insufficient computing resources, we expect even more corruption when deploying the recording and streaming tasks on the ZED Box MINI, which has more limited resources.

Is there any way to resolve this issue by adjusting the camera settings?

This is not true because this problem only affects USB 3 devices. The ZED X Mini is a GMSL2 camera.

The PC seems to be powerful enough to avoid buffer overflow issues.

  • Is the USB 3 connection stable?
  • Are the screws of the connector strongly strengthened?
  • What’s the length of the cable?
  • Are you using USB 3 hubs?
1 Like

Thank you for your kind reply.

I simply tightened the screw and switched the USB port, and it worked.
It turns out the camera was connected to a BIOS USB port.

Thanks again!

1 Like