App is freezing after sometime and it doesn't throw any exceptions

• Hardware Platform (Jetson / GPU) Jetson NX
• DeepStream Version 5.0
• JetPack Version (valid for Jetson only) 4.4

I have 4 rtsp sources and if any of them crashes, pipeline wont function properly. So I started using a python subprocess which restarts pipeline if any of the source stops streaming.

But my app is running for sometime and after that it is freezing, doesn’t throw any errors or exceptions in the logs. If I restart it again, it runs well for sometime and it freezes after sometime.

Before starting the app, I am checking all the active cameras using opencv(cv2.VideoCapture()) and adding only them to the pipeline. A thread will be running and if any of the camera which was down earlier, is up now, will restart the pipeline accordingly.

I started seeing below listed warnings frequently in my logs,

Nov 09 12:22:54 cortex0002 gunicorn[5308]: [ WARN:1] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (1757) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module source reported: Could not open resource for reading and writing.
Nov 09 12:22:54 cortex0002 gunicorn[5308]: [ WARN:1] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (886) open OpenCV | GStreamer warning: unable to start pipeline
Nov 09 12:22:54 cortex0002 gunicorn[5308]: [ WARN:1] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Nov 09 12:22:54 cortex0002 gunicorn[5308]: [tcp @ 0x7f84015910] Connection to tcp://172.17.2.2:554?timeout=0 failed: No route to host
Nov 09 12:22:57 cortex0002 gunicorn[5308]: [ WARN:2] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (1757) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module source reported: Could not open resource for reading and writing.
Nov 09 12:22:57 cortex0002 gunicorn[5308]: [ WARN:2] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (886) open OpenCV | GStreamer warning: unable to start pipeline
Nov 09 12:22:57 cortex0002 gunicorn[5308]: [ WARN:2] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Nov 09 12:22:57 cortex0002 gunicorn[5308]: [tcp @ 0x7f7c017540] Connection to tcp://172.17.2.164:554?timeout=0 failed: No route to host
Nov 09 12:23:00 cortex0002 gunicorn[5308]: [ WARN:3] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (1757) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module source reported: Could not open resource for reading and writing.

Can someone help me in resolving this?

From the log, the RTSP connection is not successful. So it stoped.

Could not open resource for reading and writing

I am receiving the warnings from initially itself. The app is running fine for sometime even with the above warnings and freezing after sometime. Pipeline is running but I couldn’t see anything in the logs.

Also could you please suggest any way to check if a camera is active in list and cameras and add only them to pipeline using deepstream?

Now I am doing using opencv and I feel there must be a way to do this in deepstream in python

Do you mean how to check whether rtsp server is connected? For deepstream, when the pipeline fail, the bus_call will receive the error message.

Okay. I do understand that I receive a message in bus_call but it is only after I created the pipeline.

Say for instance, I have 4 cameras and two among them are active. While creating a pipeline, I want to add only this two cameras to the pipeline and run it. After sometime if any of the de active cameras is up, I want to restart the pipeline with the camera which is up now.

The camera status should be checked outside pipeline before you use the pipeline. We can not give you any suggestion from DeepStream point of view.

Can we use deepstream to check if a particular camera is up and add that to pipeline?

I want to use only deepstream and know the active cameras. Can you suggest any on the same?

deepstream does not provide such API now.

I was going through the forum and found this. In the mentioned link, I noticed they are using gstreamer inside cv2.VideoCapture(). Could you please shed some light on using gstremer inside cv2.VideoCapture as above, if possible with a working example?

There are some third party open source for it. E.G. https://gist.github.com/jkjung-avt/86b60a7723b97da19f7bfa3cb7d2690e