I have a deepstream application using the python api, similar to the sample app “runtime_source_add_delete”.
I would like for my application to be able to dynamically add new sources (uris of video files) as they are sent from a server.
Three questions:
Is there any sample application doing something similar? Looping and listening for some “outside trigger” to add elements to the pipeline. That would be super helpful.
Is there any sample application doing something similar? Looping and listening for some “outside trigger” to add elements to the pipeline. That would be super helpful.
There is no sample to dynamically add sources to a DeepStream pipeline.
For your use case, you can build your solution based on modifying existing samples like deepstream-test5 (which handles multiple streams and metadata) and apply the following techniques:
Use a Controller Thread or Async Function: Implement a secondary thread or async function that listens for new video URIs from your server. This would run concurrently with your GStreamer pipeline.
Dynamically Manage Sources: As far as I know, you can’t add pads to nvstreammux on the fly. However, you can stop the pipeline or a portion of it, add the new source, link it to a new pad in nvstreammux, adjust the batch size, and then restart the pipeline. One way to do this is to keep the pipeline components modular using GstD to manage them as sub-pipelines. Since DeepStream optimizes performance based on batch size, you may need to generate multiple engines depending on the required batch sizes or use a batch size of 1and lose on performance.
The DeepStream REST Server is primarily C-based, you can implement similar behavior in Python by setting up your own HTTP server and having it control the DeepStream pipeline based on incoming requests. For example, you can have endpoints that add or remove sources dynamically by communicating with your main pipeline thread.
(This is a bit random in regards to the above problem, but I still wonder how things are done in Python…) I found the “gst_message_new_application” in the gst documentation: GstMessage . If I would want to use this in my python-application, could that be done?
Yes, you can use GStreamer’s gst_message_new_application in Python with the GObject bindings (gi.repository.Gst). To send a custom message to the pipeline’s bus, you would do something like this:
nvmultiurisrcbin is a plugin. you can create it by referring to this code. please refer to this link for a sample pipeline. please refer to this link for a REST API sample.
This is resolved! I managed to test both the nvmultiurisrcbin which works great, and I used the sample python app I linked above ^ for inspiration to create my own solution of adding a new source when a playing source reports EOS. Thank you for the help! :)