How to turn ON/OFF camera when the internet connection or RTSP server is unstable using Gstreamer and Python

Please provide complete information as applicable to your setup.

**• T4/ A6000
**• DS6.1.1
**• 8.4.1.5
**• 11.7
• Issue Type( questions, new requirements, bugs)

I am having an issue with my Deepstream pipeline, which has RTSP connection few cameras. When the internet connection is unstable, I cannot resume the connection to the camera, but I can resume the connection to the local RTSP server. I have noticed two different logs appear in this situation: one with a timeout error and the other with a “server connection closed” error. I’ve used runtime_source_add_delete script as a baseline. As I said, I can use it when I “turn off” the local camera manually using a simple RTSP server. Still, when I turn off the camera from the electricity, the pipeline generates different results.

We have RTSP reconnection sample in deepstream-app source code. Please refer to /opt/nvidia/deepstream/deepstream/sources/apps/apps-common/src/deepstream_source_bin.c and other related source codes.

First of all, thank you for your answer.
I’ve been using a python implementation of add delete camera. And actually, it works as expected when:

  1. Connection with the camera is stable
  2. Camera is turned off manually means RTSP server closes the connection

Above I see the message “server closed connection” in GStreamer logs.

Unfortunately, when it comes to the case where the camera is down, whether by internet connection, electricity, etc. I’ve seen timeout errors
rtspsrc gstrtspsrc.c:3457:on_timeout_common:<source> source e16dcc3c, stream e16dcc3c in session 0 timed out
and then
gst-stream-error-quark: Internal data stream error. (1): gstrtspsrc.c(6056): gst_rtspsrc_loop (): /GstPipeline:pipeline0/GstURIDecodeBin:source-bin-01/GstRTSPSrc:source: streaming stopped, reason error (-5)

Is it possible to repair/debug the error? I mean
a) Which element in the pipeline generates the error
b) Send close the connection message inside the pipeline

a) rtspsrc (gstreamer.freedesktop.org) failed to connected with the RTSP server(the camera).
b) The pipeline already get the error. Since the connection is broken, you can not send anything to server. The server is abnormal, client can do nothing.

So, what would be the solution to reconnecting with a camera? I have ~10 cameras connected to the deepstream pipeline, and sometimes, we can have unstable connections with one of them. Does this mean I cannot reconnect with the camera again except by restarting the whole engine?

Is there any process to manage the server(the camera)? The DeepStream app is just RTSP client, it can not manage server. The client side reconnection is implemented in deepstream-app sample(c/c++).

No, cameras are mainly self-managed. I’m only connecting to a specific port/address.

Is there any example based on python for camera reconnection? As I said, I’ve implemented add/delete camera based on the Nvidia example, and it works as expected. Moreover, it works also for the local RTSP server when I manually down the camera stream. But it doesn’t work when the internet connection is unstable OR a camera is powered off.

We don’t have c/c++ sample now. GStreamer also supports python bindings( Python GStreamer Tutorial (brettviren.github.io)). You may need to implement by yourself.

My goal is to build a resistant and stable deepstream pipeline, but when it comes to handling multiple streams, which could be unstable in the future, no matter why internet stability, a camera powered off, RTSP server, etc. I want to be sure that the deepstream pipeline will be trying to reconnect to the camera and connects when the camera is available. As I said earlier, I’ve implemented time callback in the GStreamer, added a bus handling message, and a reconnection pool which checks the camera’s connection. However, it still doesn’t work regarding internet/camera stability. Even if I can connect to the camera after a while, manually deepstream can’t. Only restarting the pipeline helps.

Could you give me a recommendation or insights on implementing this in Python? It is a crucial feature for the application to scale efficiently and be resistant, but I can’t do this based on deepstream.

Actually it is a GStreamer issue but not DeepStream. You may try with our deepstream-app sample (c/c++). We don’t have python sample, you may need to implement by yourself.

In my opinion, it is a deepstream issue because Deepstream is mainly based on Gstreamer.

I wrote that the add-delete example from the deepstream repository doesn’t work for the most popular and easy-to-write example case when the connection with the camera is unstable. I understand you cannot help me because deepstream can’t manage streams effectively.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.