EOS is sent twice for the same stream in dynamic sink addition/removal

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) GPU
• DeepStream Version 6.3
• NVIDIA GPU Driver Version (valid for GPU only) 535.113.01
• Issue Type( questions, new requirements, bugs) questions
• Language python

My pipeline is able to dynamically add/remove sink when new source is added/removed. Refer to this question, I create a similar pipeline with some modification for my own problem, but in overview, it is quite similar.
…-> queue → nvstreamdemux → (queue → nvosd → nvvideoconvert → capsfilter → x264enc → h264parse → muxer → splitmuxsink). The subgraph inside the round brackets is wrapped as a sink_bin, this part will be created when new video is added, and removed when the video is done.

The problem is when doing following steps:

  1. The pipeline starts running with video 1, an output video is created.
  2. After a few seconds, video 2 is added, new output video is created.
  3. When the video 1 is done, bus_call gets an EOS event for video 1.
  4. When the video 2 is done, bus_call gets two more EOS events(one for the video 1 and one for the video 2).

My expectation are:

  1. When the video 2 is done, only EOS event of the video 2 is gotten in bus_call.
  2. For video 1, new output videos must be created every 10 seconds(b/c I use splitmuxsink with max-size-time = 10_000000000), however, only until the video 2 is done, remaining videos are created for video 1.

What could be the root cause of this? If you guys need more information, please let me know.
Thank you.

Could you attach your ptoject to us so that we can reproduce that in our environment?

I am sorry that I cannot show the project.
The basic idea is when new source is added, I create new sink_bin, then linking sink_pad of the bin with streamdemux source pad. Upon completion of the source, I perform a reversal by unlinking then release source pad of the streamdemux.
If possible, can you provide some suggestions/assumptions on those issues?

In theory, you need to ensure that the sink_id of the streammux and source_id of the streamdemux from the same source can correspond. Since your project is not publicly available, could you provide a simple demo to reproduce the issue you described?

demo.log (71.1 KB)
demo.py.txt (34.9 KB)

Hi @yuweiw
Attached, you will find both the main file and the log. Please help me to modify the URIs of the two videos(search TODO 1) and the config for PGIE(TODO 2) before running the main file.

As you will see in the log file, the message “Got EOS events from stream_id: 0” appears not only one time. Besides, output videos for video 1 is not generated enough.

Thank you for helping me to check it.

OK. When I just change the source and config file.

INPUT_URIS = ["file:///opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.mp4", "file:////opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.mp4"]

human_detector.set_property("config-file-path", "dstest1_pgie_config.txt")

It cannot run well. Is that how you run it, python3 demo.py?

Hi @yuweiw
Yes, I run using python3 demo.py
Can you attach the log file?

Yes. It seems that the pipeline cannot run well.
log.txt (19.5 KB)

Hi @yuweiw
I tried using your config and sample videos, this is the log. I think there are some problems with your env. My base docker is nvcr.io/nvidia/deepstream:6.3-samples
demo_v1.log (221.3 KB)

I use the deepstream:6.3-triton-multiarch docker. This is my log. I cannot reproduce the issue you mentioned.
demo.log (69.1 KB)
Can you simplify your code and keep only the core logic? This makes it easier for us to analyze that. Thanks

Hi @yuweiw,
Thank you for following up with me. The current pipeline contains only necessary parts to reproduce the issue.

Your resource seems strong so it finishes the pipeline before this condition(line 535) met: if GLOBAL_CNT == 20:

Can you please help me to set lower value, e.g. if GLOBAL_CNT == 5:, so that it adds the second source to the running pipeline.

Recently, after more investigation, I suspect that the issue comes from splitmuxsink element. When one source is finished and the other is running, it kept posting eos event on the bus everytime splitmuxsink of the remaining source triggers new segment.

Is there anyway to prevent that?

If the issue comes from splitmuxsink, You may need to file a topic to the Gstreamer forum. This plugin is a native plugin of Gstreamer. How do you confirm that this eos is from splixmuxsink? If you can identify it, you can do some special processing in the buscall.

Hi @yuweiw,
after one stream finished, the frequency of eos events sent to the bus appears proportionally with the split_max_time of remaining sink. Can we conclude that the splitmuxsink is the root cause?

I also tried setting the remaining sink’s state to NULL when the first stream finished, then set back to PLAYING, now the eos message is gone, but it does not produce output videos anymore.

When you say eos, are you referring to the Gst.MessageType.EOS or stream-eos? If the eos message means Gst.MessageType.EOS, the splitmuxsink maybe the root cause. But if it’s stream-eos, the root cause should not be related to splitmuxsink.