Add new source_bin with osdsinkpad

• Hardware Platform (Jetson / GPU) Jetson TX2
• DeepStream Version Deepstream 5.0
• JetPack Version (valid for Jetson only) 4.3

Hello, i’m trying to add new source to my pipeline according this example: deepstream_python_apps/deepstream_rt_src_add_del.py at master · NVIDIA-AI-IOT/deepstream_python_apps · GitHub

But i have two problems:

  1. source_bin.set_state(Gst.State.NULL) - breaks the application with this error:
Error: gst-resource-error-quark: Unhandled error (9): gstrtspsrc.c(6161): gst_rtspsrc_send (): /GstPipeline:pipeline0/GstBin:source-bin-00/GstURIDecodeBin:uri-decode-bin/GstRTSPSrc:source:
Option not supported (551)
  1. I have osdsinkpad function:
osdsinkpad = nvosd.get_static_pad("sink")
        if not osdsinkpad:
            sys.stderr.write(" Unable to get sink pad of nvosd \n")
        osdsinkpad.add_probe(Gst.PadProbeType.BUFFER, self.osd_sink_pad_buffer_probe, 0)

And it doesn’t work with the new source.

How can i add new source_bin with working osdsinkpad function? Or its impossible and this example works only for deepstream 5.1 and higher versions?

===>How can i add new source_bin with working osdsinkpad function?
It looks like that it’s a problem of your code.You can run our demo code first and understand the flow of the code. Then you can modify the code by yourself.
The code attached looks fine. You also can refer the deepstream_test_1.py to add the function.
===>Or its impossible and this example works only for deepstream 5.1 and higher versions?
No, but we sugget you use the latest version.

Thanks for the quick response! But osdsinkpad works great untill i remove the source. When I remove the source and add a new one - this function stops working. I tried adding again as described above, referring to nvosd. But it is not added.

osdsinkpad = self.nvosd.get_static_pad("sink")
        if not osdsinkpad:
            sys.stderr.write(" Unable to get sink pad of nvosd \n")
        osdsinkpad.add_probe(Gst.PadProbeType.BUFFER, self.osd_sink_pad_buffer_probe, 0)

Maybe there is something wrong with the way you delete the source. Could you try to add the add_probe to our demo source deepstream_rt_src_add_del and run it?

Maybe. When I remove the source - I can’t do this:

source_bin.set_state(Gst.State.NULL)

This breaks the application. So I have to remove it without this instruction.

We set NULL state at the last of the App. It means the whole program finishes. You cannot do anything after that.

But in the example when deleting the source it is:

state_return = g_source_bin_list[source_id].set_state(Gst.State.NULL)

I do the same with my source:

source_bin.set_state(Gst.State.NULL)

And it crashes the app

I mean the state of pipeline is set NULL at the last of the App. The state of plugin should set NULL at the end of it. There may be some problems with your code process. You can compare the process with our demo first.

I think I figured out what’s wrong. When I run source, the probe is only added to the first one. When I add a new source, the probe is not added to it. Question: how to add a probe for each new source?
It turns out that I need to rebuild the entire pipeline and link it when I add a new source?

I add the probe in our source code, it works well. You add the probe to the osd plugin and this plugin does not change dynamically. There may be some problems with the processing of some states in your code. You can compare it with our demo code.

It turns out that the osd plugin cannot get a new source that was added dynamically?

It can get a new source. There may be some problems with the states of the plugins when you add/delete it in your code. Could you minimize your own code and attach it?

Hello! Of course!
deepstream_add_delete.py (13.7 KB)

You didn’t add the new thread to run your source_add code like:GLib.timeout_add_seconds(10, add_sources, g_source_bin_list). You’d better use our demo code first, then change to the way you need step by step.

Seems i solve it! This is the way i add/delete source_bin with osdsinkpad in runtime:
deepstream_add_delete.py (13.7 KB)
I will be glad if you have any comments on the method!

1 Like

Glad to hear that. It seems that it’s the following code fix the issue:

        padname = "sink_%u" % int(len(self.bin_list.values()) + 1)
        sinkpad = self.streammux.get_request_pad(padname)
        if not sinkpad:
            sys.stderr.write("Unable to create sink pad bin \n")
        srcpad = new_source_bin.get_static_pad("src")
        if not srcpad:
            sys.stderr.write("Unable to create src pad bin \n")
        srcpad.link(sinkpad)
1 Like

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