ZED X Stereo: Can't record if I set_from_stream from localhost

Hi,
Since my previous post, I have downgraded the SDK to 4.2.5, but things aren’t working as they should.

I’m trying to run this simple script to record from a zed x mono stereo pair, which works if I use one IP but not localhost.

import pyzed.sl as sl
import time

# Camera
zed = sl.Camera()

# Init
init = sl.InitParameters()
init.camera_fps = 15
init.depth_mode = sl.DEPTH_MODE.NONE
init.sdk_verbose = 1
#init.set_from_stream("192.168.1.12", 34000) # WORKS!
init.set_from_stream("127.0.0.1", 34000) # DOES NOT WORK
status = zed.open(init) 
if status != sl.ERROR_CODE.SUCCESS: 
    print("Camera Open", status, "Exit program.")
    exit(1)

# Recording

recordingParameters = sl.RecordingParameters() # --- IT FAILS WITH 127.0.0.1 with recording parameters
recordingParameters.compression_mode = sl.SVO_COMPRESSION_MODE.H264
recordingParameters.video_filename = "./teste.svo"
status = zed.enable_recording(recordingParameters)
if status != sl.ERROR_CODE.SUCCESS: 
    print("Camera Open", status, "Exit program.")
    exit(1)


# Runtime
runtime = sl.RuntimeParameters()
image = sl.Mat()
i = 0
start = time.perf_counter()   # high-resolution timer
while time.perf_counter() - start < 15.0:
    if zed.grab(runtime) == sl.ERROR_CODE.SUCCESS:
        print("\tsuccess "+ str(i))
        i+=1
        zed.retrieve_image(image, sl.VIEW.LEFT) # Retrieve the left image
    else:
        print("\tfailure " + str(i))

# Close the camera
zed.disable_recording()
zed.close()

I ran this script by streaming using ip 192.168.1.12 and 127.0.0.1 (localhost). The first works fine, the second does not. Here’s the logs of both:

192.168.1.12

/bin/python /home/user/Desktop/code_zedx/record.pyuser@GTW-ONX16-ubuntu:~/Desktop/code_zedx$ /bin/python /home/user/Desktop/code_zedx/record.py
[2025-05-14 15:03:01 UTC][ZED][INFO] Logging level INFO
[2025-05-14 15:03:01 UTC][ZED][INFO] Logging level INFO
[2025-05-14 15:03:01 UTC][ZED][INFO] Logging level INFO
[Streaming] Warning : receiving port 34000 is not available (already used)... switching to port 34002. Retrying...
[Streaming] Metadata timeout. the size is equal to 196 instead of 21960. Skipping.
[Streaming] No backward compatibility required.
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 279 
NvMMLiteBlockCreate : Block : BlockType = 279 
[2025-05-14 15:03:01 UTC][ZED][INFO] [Init]  Depth mode: NONE
[2025-05-14 15:03:01 UTC][ZED][INFO] [Init]  Serial Number: S/N 106758411
[2025-05-14 15:03:05 UTC][ZED][WARNING] [Init]  Self-calibration failed. Point the camera towards a more textured and brighter area. Avoid objects closer than 1 meter (Error code: 0x01) 
        success 0
        success 1
        success 2
        success 3
        success 4
        success 5
        success 6
        success 7
        success 8
        success 9
        success 10
        success 11
...

127.0.0.1 (localhost)

/bin/python /home/user/Desktop/code_zedx/record.py
user@GTW-ONX16-ubuntu:~/Desktop/code_zedx$ /bin/python /home/user/Desktop/code_zedx/record.py
[2025-05-14 15:19:47 UTC][ZED][INFO] Logging level INFO
[2025-05-14 15:19:47 UTC][ZED][INFO] Logging level INFO
[2025-05-14 15:19:47 UTC][ZED][INFO] Logging level INFO
[ZED][Streaming] Switching to SHM-boost backend input
[Streaming] Warning : receiving port 34000 is not available (already used)... switching to port 34002. Retrying...
[Streaming] No backward compatibility required.
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 279 
NvMMLiteBlockCreate : Block : BlockType = 279 
[2025-05-14 15:19:47 UTC][ZED][INFO] [Init]  Depth mode: NONE
[2025-05-14 15:19:47 UTC][ZED][INFO] [Init]  Serial Number: S/N 106758411
[2025-05-14 15:19:50 UTC][ZED][WARNING] [Init]  Self-calibration failed. Point the camera towards a more textured and brighter area. Avoid objects closer than 1 meter (Error code: 0x01) 
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 4 
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
875967048
842091865
H264: Profile = 77 Level = 50 
NvMMLiteNvVideoCreate:3938: NvVideoEncodeCreate failed 
NvVideo: 4173: Failed to create Video encoder 
VENC: NvVideoEncBlockReportError: 2469: BlockSide error 0x4
NvVideoEnc: BlockError 
NvVideoEncTransferCaptureBufferToBlock: DoWork failed line# 644 
VENC: NvVideoEncBlockReportError: 2469: BlockSide error 0x4
NvVideoEnc: BlockError 
NvVideoEncTransferCaptureBufferToBlock: DoWork failed line# 644 
VENC: NvVideoEncBlockReportError: 2469: BlockSide error 0x4
NvVideoEnc: BlockError 
NvVideoEncTransferCaptureBufferToBlock: DoWork failed line# 644 
Segmentation fault (core dumped)
user@GTW-ONX16-ubuntu:~/Desktop/code_zedx$ 

Here’s the zed_media_server_cli.server logs of that time:

4 15:16:59 GTW-ONX16-ubuntu ZED_Media_Server[6600]: [ZED][Streaming] Adding Receiver with IP: 192.168.1.12
May 14 15:17:10 GTW-ONX16-ubuntu ZED_Media_Server[6600]: [ZED][Streaming] Removing Receiver with IP: 192.168.1.12
May 14 15:17:13 GTW-ONX16-ubuntu ZED_Media_Server[6600]: [ZED][Streaming] Adding Receiver with IP: 127.0.0.1
May 14 15:17:23 GTW-ONX16-ubuntu ZED_Media_Server[6600]: [ZED][Streaming] Removing Receiver with IP: 127.0.0.1
May 14 15:18:04 GTW-ONX16-ubuntu ZED_Media_Server[6600]: [ZED][Streaming] Adding Receiver with IP: 127.0.0.1
May 14 15:18:14 GTW-ONX16-ubuntu ZED_Media_Server[6600]: [ZED][Streaming] Removing Receiver with IP: 127.0.0.1
May 14 15:19:16 GTW-ONX16-ubuntu ZED_Media_Server[6600]: (Argus) Error Timeout:  (propagating from src/rpc/socket/client/ClientSocketManager.cpp, function send(), line 137)
May 14 15:19:16 GTW-ONX16-ubuntu ZED_Media_Server[6600]: (Argus) Error Timeout:  (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function dispatch(), line 92)
May 14 15:19:16 GTW-ONX16-ubuntu ZED_Media_Server[6600]: (Argus) Error Timeout:  (propagating from src/rpc/socket/client/ClientSocketManager.cpp, function send(), line 137)
May 14 15:19:16 GTW-ONX16-ubuntu ZED_Media_Server[6600]: (Argus) Error Timeout:  (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function dispatch(), line 92)
May 14 15:19:16 GTW-ONX16-ubuntu ZED_Media_Server[6600]: (Argus) Error FileOperationFailed: Failed socket read: Connection reset by peer (in src/rpc/socket/common/SocketUtils.cpp, function readSocket(), line 79)
May 14 15:19:16 GTW-ONX16-ubuntu ZED_Media_Server[6600]: (Argus) Error FileOperationFailed: Unexpected error in reading socket (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadCore(), line 277)
May 14 15:19:16 GTW-ONX16-ubuntu ZED_Media_Server[6600]: (Argus) Error FileOperationFailed: Receive worker failure, notifying 3 waiting threads (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadCore(), line 350)
May 14 15:19:16 GTW-ONX16-ubuntu ZED_Media_Server[6600]: (Argus) Error InvalidState: Argus client is exiting with 3 outstanding client threads (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadCore(), line 366)
May 14 15:19:16 GTW-ONX16-ubuntu ZED_Media_Server[6600]: (Argus) Error FileOperationFailed: Receiving thread terminated with error (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadWrapper(), line 379)
May 14 15:19:16 GTW-ONX16-ubuntu ZED_Media_Server[6600]: (Argus) Error FileOperationFailed: Client thread received an error from socket (in src/rpc/socket/client/ClientSocketManager.cpp, function send(), line 145)
May 14 15:19:16 GTW-ONX16-ubuntu ZED_Media_Server[6600]: (Argus) Error FileOperationFailed:  (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function dispatch(), line 92)
May 14 15:19:25 GTW-ONX16-ubuntu systemd[1]: zed_media_server_cli.service: A process of this unit has been killed by the OOM killer.
May 14 15:19:27 GTW-ONX16-ubuntu systemd[1]: zed_media_server_cli.service: Main process exited, code=killed, status=9/KILL
May 14 15:19:27 GTW-ONX16-ubuntu systemd[1]: zed_media_server_cli.service: Failed with result 'oom-kill'.
May 14 15:19:27 GTW-ONX16-ubuntu systemd[1]: zed_media_server_cli.service: Consumed 8min 20.544s CPU time.
May 14 15:19:28 GTW-ONX16-ubuntu systemd[1]: zed_media_server_cli.service: Scheduled restart job, restart counter is at 1.
May 14 15:19:28 GTW-ONX16-ubuntu systemd[1]: Stopped ZED Media Server.
May 14 15:19:28 GTW-ONX16-ubuntu systemd[1]: zed_media_server_cli.service: Consumed 8min 20.544s CPU time.
May 14 15:19:28 GTW-ONX16-ubuntu systemd[1]: Started ZED Media Server.
May 14 15:19:29 GTW-ONX16-ubuntu ZED_Media_Server[7171]: [ZEDMediaServer] Version  0.1.8
May 14 15:19:29 GTW-ONX16-ubuntu ZED_Media_Server[7171]: ** CLI version **
May 14 15:19:29 GTW-ONX16-ubuntu sudo[7180]:     root : PWD=/ ; USER=root ; COMMAND=/usr/bin/systemctl restart nvargus-daemon
May 14 15:19:29 GTW-ONX16-ubuntu sudo[7180]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0)
May 14 15:19:29 GTW-ONX16-ubuntu sudo[7180]: pam_unix(sudo:session): session closed for user root
May 14 15:19:34 GTW-ONX16-ubuntu ZED_Media_Server[7171]: [ZXCamera] Camera  314383743  opened at resolution  3840  x  2160  and fps  15
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: [ZXCamera] Camera  316946451  opened at resolution  3840  x  2160  and fps  15
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: [Streaming] Use Transport layer mode : 2
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: [Streaming] Use SHM-Boost IPC backend
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: NvMMLiteOpen : Block : BlockType = 8
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: ===== NvVideo: NVENC =====
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: NvMMLiteBlockCreate : Block : BlockType = 8
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: Opening in BLOCKING MODE
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: 892744264
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: 842091865
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: NvVideo: H265 : Profile : 1
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: [VirtualCameraStreamer] Creating Streamer for  3840 x 2160 @ 15
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: [VirtualCameraStreamer] --> Enter <--
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: NVMEDIA: Need to set EMC bandwidth : 1436000
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: NvVideo: bBlitMode is set to TRUE
May 14 15:19:36 GTW-ONX16-ubuntu ZED_Media_Server[7171]: [Streaming] Streaming is now running....
May 14 15:19:47 GTW-ONX16-ubuntu ZED_Media_Server[7171]: [ZED][Streaming] Adding Receiver with IP: 127.0.0.1
May 14 15:19:57 GTW-ONX16-ubuntu ZED_Media_Server[7171]: [ZED][Streaming] Removing Receiver with IP: 127.0.0.1

If I run this a couple times, ocasionally, instead of segfaulting, I get a slightly different log and it will hang instead of terminating by itself:

user@GTW-ONX16-ubuntu:~/Desktop/code_zedx$ /bin/python /home/user/Desktop/code_zedx/record.py
[2025-05-14 15:23:23 UTC][ZED][INFO] Logging level INFO
[2025-05-14 15:23:23 UTC][ZED][INFO] Logging level INFO
[2025-05-14 15:23:23 UTC][ZED][INFO] Logging level INFO
[ZED][Streaming] Switching to SHM-boost backend input
[Streaming] Warning : receiving port 34000 is not available (already used)... switching to port 34002. Retrying...
[Streaming] No backward compatibility required.
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 279 
NvMMLiteBlockCreate : Block : BlockType = 279 
[2025-05-14 15:23:23 UTC][ZED][INFO] [Init]  Depth mode: NONE
[2025-05-14 15:23:23 UTC][ZED][INFO] [Init]  Serial Number: S/N 106758411
[2025-05-14 15:23:26 UTC][ZED][WARNING] [Init]  Self-calibration failed. Point the camera towards a more textured and brighter area. Avoid objects closer than 1 meter (Error code: 0x01) 
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 4 
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
875967048
842091865
H264: Profile = 77 Level = 50 
NvMMLiteNvVideoCreate:3938: NvVideoEncodeCreate failed 
NvVideo: 4173: Failed to create Video encoder 
VENC: NvVideoEncBlockReportError: 2469: BlockSide error 0x4
NvVideoEnc: BlockError 
NvVideoEncTransferCaptureBufferToBlock: DoWork failed line# 644 
VENC: NvVideoEncBlockReportError: 2469: BlockSide error 0x4
NvVideoEnc: BlockError 
NvVideoEncTransferCaptureBufferToBlock: DoWork failed line# 644 
VENC: NvVideoEncBlockReportError: 2469: BlockSide error 0x4
NvVideoEnc: BlockError 
NvVideoEncTransferCaptureBufferToBlock: DoWork failed line# 644 
[2025-05-14 15:23:42 UTC][ZED][WARNING] CAMERA NOT INITIALIZED in sl::ERROR_CODE sl::Camera::grab(sl::RuntimeParameters)
        failure 0
[ERROR] (/builds/sl/ZEDKit/lib/src/sl_input/mmapi/R364/NvV4l2ElementPlane.cpp:256) <> Capture Plane:Error while Qing buffer: Device or resource busy
[ERROR] (/builds/sl/ZEDKit/lib/src/sl_input/mmapi/R364/NvV4l2ElementPlane.cpp:178) <> Capture Plane:Error while DQing buffer: Invalid argument

I am running L4T=36.4.3 and I also found out that there are problems when I run ZED_Diagnostic. Here’s the logs:
ZED_Diagnostic_Results.json (5.2 KB).

I can’t understand what I am doing wrong. Is the 36.4.3 not supported?

Hello Tiago,

Thank you for reaching us again. We are trying to reproduce the issue.
By waiting, could you please try to comment the line which enables the recording status = zed.enable_recording(recordingParameters) and to run your script with your setup. Does it still fail for (“127.0.0.1”, 34000) and not for (“192.168.1.12”, 34000) ?

Best regards,

Stereolabs Support

Works fine without recording. It’s really the combination of localhost + enable_recording.

I should also add some other evidence resulting from my experiences:

  • I went back to SDK 5 and it does not work with it as well. It’s the exact same behavior. The combo localhost + enable_recording does not work in both versions. So it’s probably not a version problem.
  • With SDK 5, the diagnostic results are perfect, as opposed to those I uploaded with SDK 4.2.5, so the problem is probably not the drivers
  • I also wrote the same code in cpp, and tried it in both SDK 4.2.5 and 5 and the same results persist, so it’s not a python thing.

There’s also something else that I do not know if it is related or not, which is the fact that I can not set any settings. For example, trying to change the compression or brightness… it does not work both in code or in the ZED Explorer. There is no error, just nothing happens. I was going to open another post with this one, but maybe it’s better if I keep it here, at least until we solve the first problem in case it is related. Tell me if you want me to elaborate on this or you think it’s not related.

Anyway, thank you for your help – I’m really excited for this product and hope to make it work!

Hello Tiago,

Sorry for my late answer, we worked on the issue and it should be fixed in the next SDK version. Please stay tuned and update your SDK as soon as it is online.

Thank you for your information and your patience. Do not hesitate to contact us again if you encountered any issue.

Best regards,

Stereolabs Support

1 Like