Can't add new RTSP source dynamically using NEW NVSTREAMMUX and adaptative batching

Hello everyone,

• Hardware Platform (Jetson / GPU): RTX2080TI / RTX3090
• DeepStream Version: 6.2/6.3 (Docker Deepstream)
• Issue Type( questions, new requirements, bugs): Bugs

I am trying to make a deepstream application with which I can use the NEW NVSTREAMMUX to add and remove RTSP video streams dynamically. I have detected the following scenarios with which errors occur. A minimal example to replicate the two problems detected is attached at the end of this thread:

ERROR 1. When an RTSP source connection is lost and an attempt is made to reconnect, it does not feed data to the DS stream and the transmission does not start.

Details: If EOS or RTSP error arrives, the source_bin is removed from the pipeline. This seems to be done correctly. In case you then retry to add that source, which is transmitting again, it seems to add and work correctly.

PROBLEM: An attempt is made to add a new stream that is not available (RTSP error). When this happens, after checking source unavailability, the pipeline components are removed. This causes that the subsequent source_bins that you try to include do not load correctly and do not decode the video.

How to replicate it?

  1. After the pipeline.set_state(Gst.State.PLAYING) line, include the following. This adds a new source every 15 seconds indefinitely (the uri of the first stream offered as argument is added):

    GLib.timeout_add(20000, add_streams)

  2. Start execution. After a few seconds stream 0 (first stream as argument) must be terminated so that an EOS signal is sent to DS.

    Two scenarios:

    1. Re-enable RTSP stream in a very short period of time (before DS tries to rearm it). It will work correctly.

    2. Wait for DS to try to rearm the RTSP video stream. Once it shows a failure that there is an RTSP error → Re-enable Stream RTSP. When it tries to reassemble it again, it will not expose any error. However, the source_bin will not be fully constructed and will not feed data to DS. The network generated at the time of the error is exposed:

    graph_adding_stream_after_rtsp_error.pdf (73.7 KB)

ERROR 2. Depending on the activation of adaptive batching and batch-size of the NEW NVSTREAMMUX different errors are detected.

Details: The following errors are detected when adding new sources:

  • With Adaptive-Batching enabled in NEW NVSTREAMMUX:

    • PROBLEM: If we have deleted any source we can add new ones. As long as No. Sources <= initial No. Sources. A failure is displayed by the tracker batching:

      [ERROR push 333] push failed [-5] gstnvtracker: NvBufSurfTransform failed with error -3 while converting buffergstnvtracker:

    • Tested on DS 6.3 and same error.

  • With Adaptive-Batching disabled in NEW NVSTREAMMUX:

    • It is possible to add streams larger than initial batch size. But that makes the DS stream computationally inefficient. In the given example code:

      • If batch-size equal or smaller than initial No. Streams, it allows to add new streams indefinitely.

      • PROBLEM: If batch-size greater than initial No. Streams, it gives the above tracker error when trying to add new source.

How to replicate it?

  • Adaptive-Batching enabled:

    1. Enable adaptive-batching in dstest_streammux_config.txt.

    2. After the “pipeline.set_state(Gst.State.PLAYING)” line, include the following. This removes two video sources and then every 30 seconds adds a new one indefinitely (the uri of the first stream offered as argument is added):

    GLib.timeout_add(20000, remove_one_stream)
    GLib.timeout_add(25000, remove_one_stream)
    GLib.timeout_add(30000, add_streams)
    
    1. Similarly, if DS starts with 3 Streams and a fourth one is added. The source_bin loads fine and connects to Streammux. Streammux updates batch-size to 4. However, the tracker error indicated above appears, which interrupts all the sources:

      [ERROR push 333] push failed [-5] gstnvtracker: NvBufSurfTransform failed with error -3 while converting buffergstnvtracker:

      I attach the DS network that is generated when the 4 source is added and gives the commented error:

      graph_adaptive_batching_error_adding_source.pdf (97.6 KB)

      Note: When no NVTRACKER is added, this error disappears, so it seems to be an implementation error of that module.

  • Adaptive-Batching disabled

    1. Disable adaptive-batching in dstest_streammux_config.txt.

    2. After the “pipeline.set_state(Gst.State.PLAYING)” line, include the following. This adds a new source every 15 seconds indefinitely (the uri of the first stream offered as argument is added):

    GLib.timeout_add(15000, add_streams)
    

Attached source code:

deepstream-add-remove.zip (174.9 KB)

I need my code to work with NEW NVSTREAMMUX with adaptive batching, allowing to add new sources correctly. I understand that this is not a bug in my application, as it may or may not work depending on the activation of that property and whether or not a Tracker is included.

Best regards,

Juan Isern

Hi there,

Still getting same errors & behaviour from NEW NVSTREAMMUX.

I need some help,

Thank you so much!

  1. could you highlight the issue description? we suggest focusing on one problem in one topic.
  2. is the code based on deepstream_rt_src_add_del.py? nocticing there are big code changes in deepstream-app.py, can you simplifiy the deepstream_rt_src_add_del.py to reprodcue the error?

Hi Fanzh

  1. Summarizing, the main problem is that I can’t add new sources dynamically using new nvstreammux because I get the following error, which seems to come from the nvtracker:

    [ERROR push 333] push failed [-5] gstnvtracker: NvBufSurfTransform failed with error -3 while converting buffergstnvtracker:

  2. I think the code is sufficiently self-descriptive and replicates my application very well, but I will try to make it more similar to the original example to make it easier for you to debug the problem. I will provide you with such code tomorrow morning, as I am out of the office.

Best regards,

Juan Isern

Hi again!

I have been able to replicate the problem with the original deepstream_rt_src_add_del.py example.

Problem details: On startup, the first RTSP URI is added correctly and processing starts. When adding a new RTSP source, the following error appears:

0:00:39.310300996     1      0x3959f00 WARN                 nvinfer gstnvinfer.cpp:2369:gst_nvinfer_output_loop:<primary-inference> error: Internal data stream error.
0:00:39.310306847     1      0x3959f00 WARN                 nvinfer gstnvinfer.cpp:2369:gst_nvinfer_output_loop:<primary-inference> error: streaming stopped, reason error (-5)
Error: gst-stream-error-quark: Failed to submit input to tracker (1): gstnvtracker.cpp(657): gst_nv_tracker_submit_input_buffer (): /GstPipeline:pipeline0/GstNvTracker:tracker

Note that I am using adaptive-batching and the pipeline seems to look good, as the batch is increased to the new number of sources (2):

I share the code below:

add_del_new_nvstreammux.zip (9.1 KB)

Best regards

  1. the picture “two_rtsp_fail” is not clear, please share a zip file. Thanks!
  2. are the two rtsp sources the same?

Hello Fanzh

  1. Here is the zip file with the pipeline graph:

    two_rtsp_fail.zip (1.4 MB)

  2. Indeed, the sources are the same. I have tried with the same and different sources, with the same or different resolutions. I have also added nvvideoconvert to each source before the nvstreammux, all with the same resolution, but I get the same result.

Best regards,
Juan

please use streammux.set_property(“batch-size”, 30).

Hi fanzh

I see that you propose to add the batch size of the New Nvstreammux to the same value as the PGIE. I understand that then the adaptive batching does not work or does it wrong? Is this a solution that makes sense according to the documentation?

I understand that activating the adaptive batching would not have to be indicating an explicit value. Besides this has a noticeable performance loss.

Best regards

new nvstreammux’s batch-size means “Maximum number of frames in a batch.”, if batch-size is set to 1, when adaptive batching is enabled and there are two sources, the num_frames_in_batch will be 2, which is inconsistent with max number 1.

Hi fanzh,

I have tried your changes and there are still problems. The New Nvstreammux configuration looks like this:

[property]
overall-max-fps-n=120
overall-max-fps-d=1
overall-min-fps-n=30
overall-max-fps-d=1
max-fps-control=0
batch-size=30
adaptive-batching=1

The output is as follows:

root@rtx2080ti:/var/backend/ds# python3 deepstream_rt_src_add_del.py rtsp://192.168.88.254:8554/

(gst-plugin-scanner:11): GStreamer-WARNING **: 09:36:00.888: Failed to load plugin '/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_inferserver.so': libtritonserver.so: cannot open shared object file: No such file or directory

(gst-plugin-scanner:11): GStreamer-WARNING **: 09:36:00.894: Failed to load plugin '/usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_udp.so': librivermax.so.0: cannot open shared object file: No such file or directory
Creating Pipeline 
 
Creating streammux 
 
max_fps_dur 8.33333e+06 min_fps_dur 2e+08
Creating source_bin  0  
 
Creating uridecodebin for [rtsp://192.168.88.254:8554/]
source-bin-00
Creating Pgie 
 
Creating nvtracker 
 
Creating tiler 
 
Creating nvvidconv 
 
Creating nvosd 
 
Creating EGLSink 

Adding elements to Pipeline 

Linking elements in the Pipeline 

gstnvtracker: Loading low-level lib at /opt/nvidia/deepstream/deepstream/lib/libnvds_nvmultiobjecttracker.so
gstnvtracker: Batch processing is ON
gstnvtracker: Past frame output is OFF
[NvMultiObjectTracker] Initialized
0:00:00.510272490    10      0x1fb9cc0 WARN                 nvinfer gstnvinfer.cpp:677:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::initialize() <nvdsinfer_context_impl.cpp:1170> [UID = 1]: Warning, OpenCV has been deprecated. Using NMS for clustering instead of cv::groupRectangles with topK = 20 and NMS Threshold = 0.5
WARNING: ../nvdsinfer/nvdsinfer_model_builder.cpp:1487 Deserialize engine failed because file path: /opt/nvidia/deepstream/deepstream-6.2/samples/models/Primary_Detector/resnet10.caffemodel_b30_gpu0_int8.engine open error
0:00:02.213560423    10      0x1fb9cc0 WARN                 nvinfer gstnvinfer.cpp:677:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1897> [UID = 1]: deserialize engine from file :/opt/nvidia/deepstream/deepstream-6.2/samples/models/Primary_Detector/resnet10.caffemodel_b30_gpu0_int8.engine failed
0:00:02.238830669    10      0x1fb9cc0 WARN                 nvinfer gstnvinfer.cpp:677:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2002> [UID = 1]: deserialize backend context from engine from file :/opt/nvidia/deepstream/deepstream-6.2/samples/models/Primary_Detector/resnet10.caffemodel_b30_gpu0_int8.engine failed, try rebuild
0:00:02.239314035    10      0x1fb9cc0 INFO                 nvinfer gstnvinfer.cpp:680:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1923> [UID = 1]: Trying to create engine from model files
WARNING: [TRT]: The implicit batch dimension mode has been deprecated. Please create the network with NetworkDefinitionCreationFlag::kEXPLICIT_BATCH flag whenever possible.
0:00:24.755141610    10      0x1fb9cc0 INFO                 nvinfer gstnvinfer.cpp:680:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1955> [UID = 1]: serialize cuda engine to file: /opt/nvidia/deepstream/deepstream-6.2/samples/models/Primary_Detector/resnet10.caffemodel_b4_gpu0_int8.engine successfully
INFO: ../nvdsinfer/nvdsinfer_model_builder.cpp:610 [Implicit Engine Info]: layers num: 3
0   INPUT  kFLOAT input_1         3x368x640       
1   OUTPUT kFLOAT conv2d_bbox     16x23x40        
2   OUTPUT kFLOAT conv2d_cov/Sigmoid 4x23x40         

0:00:24.785875907    10      0x1fb9cc0 INFO                 nvinfer gstnvinfer_impl.cpp:328:notifyLoadModelStatus:<primary-inference> [UID 1]: Load new model:dstest_pgie_config.txt sucessfully
Decodebin child added: source 

Now playing...
1 :  rtsp://192.168.88.254:8554/
Starting pipeline 

Decodebin child added: decodebin0 

Decodebin child added: rtph264depay0 

Decodebin child added: h264parse0 

Decodebin child added: capsfilter0 

Decodebin child added: nvv4l2decoder0 

In cb_newpad

gstname= video/x-raw
sink_0
Decodebin linked to pipeline
max_fps_dur 8.33333e+06 min_fps_dur 3.33333e+07
Calling Start 1 
Creating uridecodebin for [rtsp://192.168.88.254:8554/]
source-bin-01
Decodebin child added: source 

STATE CHANGE NO PREROLL

Decodebin child added: decodebin1 

Decodebin child added: rtph264depay1 

Decodebin child added: h264parse1 

Decodebin child added: capsfilter1 

Decodebin child added: nvv4l2decoder1 

In cb_newpad

gstname= video/x-raw
sink_1
Decodebin linked to pipeline
gstnvtracker: NvBufSurfTransform failed with error -3 while converting buffergstnvtracker: Failed to convert input batch.
0:00:35.583666826    10      0x1fb7f00 WARN                 nvinfer gstnvinfer.cpp:2369:gst_nvinfer_output_loop:<primary-inference> error: Internal data stream error.
0:00:35.583672918    10      0x1fb7f00 WARN                 nvinfer gstnvinfer.cpp:2369:gst_nvinfer_output_loop:<primary-inference> error: streaming stopped, reason error (-5)
Error: gst-stream-error-quark: Failed to submit input to tracker (1): gstnvtracker.cpp(657): gst_nv_tracker_submit_input_buffer (): /GstPipeline:pipeline0/GstNvTracker:tracker
Exiting app

free(): invalid next size (fast)
Aborted (core dumped)

Best regards

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

please delete batch-size=30 in the configuration file, then modify streammux.set_property(“batch-size”, 1) to streammux.set_property(“batch-size”, 30) in the code.

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