# The events are duplicated when linking an unliking elements to the sink pads of nvstreamux

**URL:** <https://forums.developer.nvidia.com/t/the-events-are-duplicated-when-linking-an-unliking-elements-to-the-sink-pads-of-nvstreamux/267232>\
**Category:** DeepStream SDK\
**Tags:** gstreamer, deepstream\
**Created:** [September 22, 2023, 5:20am UTC](https://forums.developer.nvidia.com/t/the-events-are-duplicated-when-linking-an-unliking-elements-to-the-sink-pads-of-nvstreamux/267232 "2023-09-22T05:20:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomskih\_pa](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@tomskih\_pa](https://forums.developer.nvidia.com/u/tomskih_pa)\
**Post date:** [September 22, 2023, 5:20am UTC](https://forums.developer.nvidia.com/t/the-events-are-duplicated-when-linking-an-unliking-elements-to-the-sink-pads-of-nvstreamux/267232/1 "2023-09-22T05:20:47Z")

</div>

Please provide complete information as applicable to your setup.

**• Hardware Platform (Jetson / GPU)**  
NVIDIA GeForce RTX 3060 Laptop GPU  
**• DeepStream Version**  
6.3.0  
**• JetPack Version (valid for Jetson only)**  
**• TensorRT Version**  
**• NVIDIA GPU Driver Version (valid for GPU only)**  
535.104.05  
**• Issue Type( questions, new requirements, bugs)**  
bug  
**• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)**

Here’s the code to reproduce the issue:

[duplicated\_events.zip](https://forums.developer.nvidia.com/uploads/short-url/dNuV5kvfncGdiGXKF3vU1fLvcV8.zip) (2.4 KB)

Build a docker image with the Dockerfile in the archive and run it for a few seconds (for me 5 seconds is enough):

```auto
docker build -t duplicated_events .
docker run --gpus all -it --rm duplicated_events 2>&1 | tee test.log

```

Then check for duplicated events in the log:

```auto
grep 'log_event_pad_probe.*nvstreamdemux0.src_0' test.log | sed -re 's/.*Event type: (.*)\. Seqnum: ([0-9]+)\..*/\2\t\1/' | sort | uniq -c | sort

...
      3 7324	<enum GST_EVENT_CAPS of type Gst.EventType>
      3 7433	<enum GST_EVENT_CAPS of type Gst.EventType>
      3 8467	<enum GST_EVENT_CAPS of type Gst.EventType>

```

```auto
grep 'Seqnum: 7324' test.log

2023-09-22 05:16:34,832 [log_event_pad_probe] [INFO] [Dummy-1] Pad: nvstreamdemux0.src_0. Event type: <enum GST_EVENT_CAPS of type Gst.EventType>. Seqnum: 7324. Struct: GstEventCaps, caps=(GstCaps)"video/x-raw\(memory:NVMM\)\,\ width\=\(int\)1280\,\ height\=\(int\)720\,\ framerate\=\(fraction\)30/1\,\ multiview-mode\=\(string\)mono\,\ format\=\(string\)I420\,\ block-linear\=\(boolean\)false\,\ nvbuf-memory-type\=\(string\)nvbuf-mem-cuda-device\,\ gpu-id\=\(int\)0\,\ batch-size\=\(int\)1\,\ num-surfaces-per-frame\=\(int\)1";.
2023-09-22 05:16:34,832 [log_event_pad_probe] [INFO] [Dummy-3] Pad: nvstreamdemux0.src_0. Event type: <enum GST_EVENT_CAPS of type Gst.EventType>. Seqnum: 7324. Struct: GstEventCaps, caps=(GstCaps)"video/x-raw\(memory:NVMM\)\,\ width\=\(int\)1280\,\ height\=\(int\)720\,\ framerate\=\(fraction\)30/1\,\ multiview-mode\=\(string\)mono\,\ format\=\(string\)I420\,\ block-linear\=\(boolean\)false\,\ nvbuf-memory-type\=\(string\)nvbuf-mem-cuda-device\,\ gpu-id\=\(int\)0\,\ batch-size\=\(int\)1\,\ num-surfaces-per-frame\=\(int\)1";.
2023-09-22 05:16:34,832 [log_event_pad_probe] [INFO] [Dummy-1] Pad: nvstreamdemux0.src_0. Event type: <enum GST_EVENT_CAPS of type Gst.EventType>. Seqnum: 7324. Struct: GstEventCaps, caps=(GstCaps)"video/x-raw\(memory:NVMM\)\,\ width\=\(int\)1280\,\ height\=\(int\)720\,\ framerate\=\(fraction\)30/1\,\ multiview-mode\=\(string\)mono\,\ format\=\(string\)I420\,\ block-linear\=\(boolean\)false\,\ nvbuf-memory-type\=\(string\)nvbuf-mem-cuda-device\,\ gpu-id\=\(int\)0\,\ batch-size\=\(int\)1\,\ num-surfaces-per-frame\=\(int\)1";.

```

```auto
grep 'log_event_pad_probe.*nvstreamdemux0.src_0' test.log | grep -v 'GST_EVENT_' | sed -re 's/.*Event type: (.*)\. Seqnum: ([0-9]+)\..*/\2\t\1/' | sort | uniq -c | sort

...
      2 34270	<enum 102942 of type Gst.EventType>
      2 41327	<enum 102942 of type Gst.EventType>
      2 6606	<enum 102942 of type Gst.EventType>

```

```auto
grep 'Seqnum: 6606' test.log

2023-09-22 05:16:34,795 [log_event_pad_probe] [INFO] [Dummy-3] Pad: nvstreammux0.src. Event type: <enum 102942 of type Gst.EventType>. Seqnum: 6606. Struct: nv-stream-eos-1-114, source-id=(uint)1;.
2023-09-22 05:16:34,796 [log_event_pad_probe] [INFO] [Dummy-3] Pad: nvstreamdemux0.src_0. Event type: <enum 102942 of type Gst.EventType>. Seqnum: 6606. Struct: nv-stream-eos-1-114, source-id=(uint)1;.
2023-09-22 05:16:34,797 [log_event_pad_probe] [INFO] [Dummy-3] Pad: nvstreamdemux0.src_0. Event type: <enum 102942 of type Gst.EventType>. Seqnum: 6606. Struct: nv-stream-eos-1-114, source-id=(uint)1;.
2023-09-22 05:16:34,797 [log_event_pad_probe] [INFO] [Dummy-3] Pad: nvstreamdemux0.src_1. Event type: <enum 102942 of type Gst.EventType>. Seqnum: 6606. Struct: nv-stream-eos-1-114, source-id=(uint)1;.
2023-09-22 05:16:34,797 [log_event_pad_probe] [INFO] [Dummy-3] Pad: nvstreammux0.src. Event type: <enum 102942 of type Gst.EventType>. Seqnum: 6606. Struct: nv-stream-eos-1-114, source-id=(uint)1;.

```

**• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)**

---

<div class="post-metadata">

**Author:** ![yuweiw](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/yuweiw/32/101255_2.png) [@yuweiw](https://forums.developer.nvidia.com/u/yuweiw)\
**Post date:** [September 22, 2023, 6:22am UTC](https://forums.developer.nvidia.com/t/the-events-are-duplicated-when-linking-an-unliking-elements-to-the-sink-pads-of-nvstreamux/267232/3 "2023-09-22T06:22:27Z")

</div>

Can you provide a detailed description of the duplicated events from your log and the problems it brings?

---

<div class="post-metadata">

**Author:** ![tomskih\_pa](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@tomskih\_pa](https://forums.developer.nvidia.com/u/tomskih_pa)\
**Post date:** [September 22, 2023, 7:32am UTC](https://forums.developer.nvidia.com/t/the-events-are-duplicated-when-linking-an-unliking-elements-to-the-sink-pads-of-nvstreamux/267232/4 "2023-09-22T07:32:10Z")

</div>

In the logs you can see the same event `GST_EVENT_CAPS` (`seqnum=7324`) was received by `nvstreamdemux0.src_0` 3 times, event `nv-stream-eos-1-114` (`seqnum=6606`) was generated by `nvstreammux0.src` 2 times. In our project ([Savant](https://github.com/insight-platform/Savant)) we’re using `nv-stream-eos` events to dynamically unlink elements from src pad of `nvstreamdemux` and remove them. Duplicating of this event can lead to removing those elements before all frames were handled. I.e.

1. Link elements to `nvstreammux.sink_0` and `nvstreamdemux.src_0`.
2. Unlink those elements after the first EOS on `nvstreammux.sink_0` and nv-stream-eos on `nvstreamdemux.src_0` are received.
3. Link new elements to `nvstreammux.sink_0` and `nvstreamdemux.src_0`.
4. `nvstreamdemux.src_0` receives the same nv-stream-eos again and we’re unlinking elements from that pad. But `nvstreammux.sink_0` didn’t receive EOS and frames are still passing through it. That leads to errors.

As a workaround we’re tracking `seqnum` of already processed events to skip duplicates. But it looks like a bug in deepstream that nvstreammux or nvstreamdemux are sending the same event again sometimes.

---

<div class="post-metadata">

**Author:** ![yuweiw](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/yuweiw/32/101255_2.png) [@yuweiw](https://forums.developer.nvidia.com/u/yuweiw)\
**Post date:** [September 26, 2023, 7:19am UTC](https://forums.developer.nvidia.com/t/the-events-are-duplicated-when-linking-an-unliking-elements-to-the-sink-pads-of-nvstreamux/267232/5 "2023-09-26T07:19:04Z")

</div>

**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**

Could you refer to our demo code : [deepstream\_rt\_src\_add\_del.py](https://github.com/NVIDIA-AI-IOT/deepstream_python_apps/blob/master/apps/runtime_source_add_delete/deepstream_rt_src_add_del.py#L165).

1. send flush stop event
2. release the pad of streammux
3. remove the plguin

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [October 10, 2023, 7:19am UTC](https://forums.developer.nvidia.com/t/the-events-are-duplicated-when-linking-an-unliking-elements-to-the-sink-pads-of-nvstreamux/267232/6 "2023-10-10T07:19:45Z")

</div>

Closed on October 10, 2023, 7:19am UTC

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