How to mux the Subbin in Primary-bin to get to Pipeline of Deepstream-app

• Hardware Platform (Jetson / GPU): Jetson Nano
• DeepStream Version: 5.1
• JetPack Version: 4.5.1
• TensorRT Version: 7.3.1

i’m trying to modify the pipeline of Primary-gie something like:
+input: 2 uri
+in primary_gie_bin: I have created 2 subbin primary_gie_0 and primary_gie_1 for 2 different models.
+I want the model infer on each Uri separately, so I used link_element_to_demux_src_pad
→ It’s problematic when I mux the subbin together !!!

Can I do this ??

->primary-bin(streamdemux -> | -> queue0->nvvidconv0->primary_gie0-> |
                             | -> queue1->nvvidconv1->primary_gie1-> | -> streammux )
->...-> secondary-bin -> ...

Thanks, hope you will respond soon
(sorry if my english is not good!)

NVGSTDS_BIN_ADD_GHOST_PAD (bin->bin, bin->streammux, "src");
NVGSTDS_BIN_ADD_GHOST_PAD (bin->bin, bin->streamdemux, "sink");    
// NVGSTDS_BIN_ADD_GHOST_PAD (bin->bin, bin->tee, "sink");
// NVGSTDS_BIN_ADD_GHOST_PAD (bin->bin, bin->queue, "src");

// if (!link_element_to_tee_src_pad (bin->tee, bin->queue)) {
//   goto done;
// }
// if (!link_element_to_tee_src_pad (bin->tee, bin->streamdemux)) {
//   goto done;
// }

// for(i=0;i<num_primary_gie;i++){

if(!link_element_to_demux_src_pad (bin->streamdemux, bin->sub_bins[0].queue, 0)){
  g_printerr("demux fail");
  goto done;

if(!link_element_to_demux_src_pad (bin->streamdemux, bin->sub_bins[1].queue, 1)){
  g_printerr("demux fail");
  goto done;

// if (!link_element_to_tee_src_pad (bin->tee, bin->sub_bins[i].queue)) {
//   goto done;
// }
// }

// it works best for 1 primary_gie (0 or 1) but 2 Element links to 1 sink-Queue are not possible !

 gst_element_link_pads(bin->sub_bins[0].primary_gie , "src", bin->queue, "sink");
 gst_element_link_pads(bin->sub_bins[1].primary_gie , "src", bin->queue, "sink");

// if I replace it with link_element_to_streammux_sink_pad in deepstream_common.c then it doesn’t seem to work

if (!link_element_to_streammux_sink_pad (bin->streammux, bin->sub_bins[0].primary_gie, 0)) {
  NVGSTDS_ERR_MSG_V ("primary_gie %d cannot be linked to mux's sink pad %p\n", 0, bin->streammux);
  goto done;
if (!link_element_to_streammux_sink_pad (bin->streammux, bin->sub_bins[1].primary_gie, 1)) {
  NVGSTDS_ERR_MSG_V ("primary_gie %d cannot be linked to mux's sink pad %p\n", 1, bin->streammux);
  goto done;

I don’t understand the pipeline, can you draw them in picture?
Which function in which source file do you want to modify? create_primary_gie_bin() in deepstream_primary_gie_bin.c?
How much do you know about gstreamer? Do you know what is GstBin and how to build a GstBin?

yes, i want to modify the function create_primary_gie_bin() in deepstream_primary_gie_bin.c into create_multi_primary_gie_bin(). Function create_multi_primary_gie_bin() consists of subbins similar to create_secondary_gie_bin() in deepstream_secondary_gie_bin.c

Since deepstream-app already have nvstreamdemux path in the code. It will mess the logic.

Can you write a new application to implement your own pipeline?

What on earth is your pipeline?

I think it’s like this

streamdemux can not be used before nvinfer. It is a wrong pipeline.

Do you have any suggestions to create multi primary gie bin ?

The multiple PGIEs can be connected after nvstreammux one by one.