How to Dynamically Add nvstreammux/nvstreamdemux Sources and Sinks After Pipeline Start in DeepStream 7.1?

**• Hardware Platform gpu : NVIDIA RTX 4000 Ada Generation Laptop GPU

• DeepStream Version : 7.1

**• NVIDIA GPU Driver Version :NVIDIA GPU Driver Version 575.51.03

• Issue Type( questions, new requirements, bugs) : bugs

I have a pipeline that consume multiple rtsp urls and demux them to multiple streams RTSP streams, the prolem,

is wheen I want to add new stream after the pipeline is running, I am using the function add_new_input_stream to add a new stream, but the new stream is not working,

this line is not working and return None

srcpad1 = streamdemux.get_request_pad("src_%u"%i)

It’s my first week interracting with deepstream, I am not sure if I am doing something wrong or if there is a bug in the code.

I would appreciate any guidance or suggestions on how to troubleshoot this issue.

There are two options.

  1. Use nvmultiurisrcbin, then add or remove sources through the Restful API.

2.Refer to deepstream_test_rt_src_add_del.

Thank you, I have already check deepstream_test_rt_add_del python version, but it doesn’t show how to handle rtsp output, and for nvmultiurisrcbin I will appreciate it if you there is any example that I can follow,

Btw can you please tellme if my approach is good when I add new input stream :
I create for each new input stream nvvideoconvert -> nvdsosd -> convertor_postosd -> caps -> nvv4l2h264enc encoder -> rtph264pay ->udp-sink

Both deepstream_test_rt_src_add_del.py and nvmultiurisrcbin are used to handle nvstreammux dynamically add and remove sources.

There is no sample code for nvstreamdemux to dynamically add and remove source currently, but this feature can be supported.

deepstream_test1_rtsp_in_rtsp_out.py demonstrate how to rtsp out.

deepstream_demux_multi_in_multi_out.py demonstrate how to use nvstreamdemux

Add nvmultiurisrcbin to the pipeline like a normal element, and then use curl to add the source, as described in the documentation

gst-launch-1.0 nvmultiurisrcbin port=9000 ip-address=localhost batched-push-timeout=33333 max-batch-size=10 drop-pipeline-eos=1 live-source=1 width=1920 height=1080 uri-list=file:///opt/nvidia/deepstream/deepstream/samples/streams/sample_1080p_h264.mp4  ! nvmultistreamtiler ! nv3dsink

curl -XPOST 'http://localhost:9000/api/v1/stream/add' -d '{
  "key": "sensor",
  "value": {
     "camera_id": "uniqueSensorID1",
     "camera_name": "front_door",
     "camera_url": "file:///opt/nvidia/deepstream/deepstream/samples/streams/sample_1080p_h264.mp4",
     "change": "camera_add",
     "metadata": {
         "resolution": "1920 x1080",
         "codec": "h264",
         "framerate": 30
     }
 },
 "headers": {
     "source": "vst",
     "created_at": "2021-06-01T14:34:13.417Z"
 }
}'


curl -XPOST 'http://localhost:9000/api/v1/stream/remove' -d '{
    "key": "sensor",
    "value": {
        "camera_id": "uniqueSensorID1",
        "camera_name": "",
        "camera_url": "",
        "change": "camera_remove",
        "metadata": {
            "resolution": "1920 x1080",
            "codec": "h264",
            "framerate": 30
        }
    },
    "headers": {
        "source": "vst",
        "created_at": "2021-06-01T14:34:13.417Z"
    }
}'

Yes, this is OK, but you can first replace the sub pipeline with fakesink to test nvstreammux, and then debug nvstreamdemux after success.

to use nvmultiurisrcbin in yc uurent situation should I only add it in my pipeline and it will handle add and delete source or I should also add create an rtsp output for each new element ? or this will replace my_add_new_source function

I have try to use nvmultiurisrcbin and I got this errors any ideas

Civetweb version: v1.16
Server running at port: 9000
uri:/api/v1/stream/add
method:POST
0:00:09.101992559 2980 0x77f6f0000b70 WARN basesrc gstbasesrc.c:3688:gst_base_src_start_complete: pad not activated yet
0:00:09.102104703 2980 0x77f6f0000b70 WARN basesrc gstbasesrc.c:3688:gst_base_src_start_complete: pad not activated yet
0:00:09.105031628 2980 0x77f6f0001290 WARN qtdemux qtdemux.c:3121:qtdemux_parse_trex: failed to find fragment defaults for stream 1
0:00:09.105105453 2980 0x77f6f0001290 WARN qtdemux qtdemux.c:3121:qtdemux_parse_trex: failed to find fragment defaults for stream 2
0:00:09.106244540 2980 0x77f6f0001290 WARN uridecodebin gsturidecodebin.c:960:unknown_type_cb:<nvurisrc_bin_src_elem> warning: No decoder available for type ‘audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, level=(string)2, base-profile=(string)lc, profile=(string)lc, codec_data=(buffer)119056e500, rate=(int)48000, channels=(int)2’.
Failed to query video capabilities: Invalid argument
0:00:09.107730876 2980 0x77f6f00014f0 WARN v4l2 gstv4l2object.c:3108:gst_v4l2_object_get_nearest_size:nvv4l2decoder0:sink Unable to try format: Unknown error -1
0:00:09.107736806 2980 0x77f6f00014f0 WARN v4l2 gstv4l2object.c:2993:gst_v4l2_object_probe_caps_for_format:nvv4l2decoder0:sink Could not probe minimum capture size for pixelformat MJPG
0:00:09.107738799 2980 0x77f6f00014f0 WARN v4l2 gstv4l2object.c:3108:gst_v4l2_object_get_nearest_size:nvv4l2decoder0:sink Unable to try format: Unknown error -1

Just think of nvmultiurisrcbin as nvstreamux which can dynamically add and delete sources.