Streams Management On-The-Fly

Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU) GTX 1650
• DeepStream Version 5
• TensorRT Version 7.0.0.11
• NVIDIA GPU Driver Version (valid for GPU only) 450.51
• Issue Type( questions, new requirements, bugs) question

Hello;
Is there any way I can change the input streams on the fly in pyhton App? I am using deepstream-test1.
I found this Repo, but it is for deepstream C++.

I implemented stream switching with the input_selector plugin for GStreamer. If the stream type is different, nveglglessink crashes, but maybe with your streams it works?

Thank you for your reply @nors
Can you point me to this code?. How can I do that?

We don’t have python sample for stream switch on-the-fly.

1 Like

I don’t have python code, but this is what I do to switch sources with the input-selector plugin, which has the name “video_switch” in my pipeline:

gboolean switch_source (GstElement * pipeline, guint index)
{
	GstPad *new_pad;
	gchar pad_name[16] = { };
	GstElement *video_switch = gst_bin_get_by_name((GstBin *) pipeline, "video_switch");

	index = index % video_switch->numsinkpads;

	g_print ("switching %d/%d\n", index, video_switch->numsinkpads);

	g_snprintf (pad_name, 15, "sink_%u", index);

	new_pad = gst_element_get_static_pad (video_switch, pad_name);

	g_object_set (G_OBJECT (video_switch), "active-pad", new_pad, NULL);
	gst_object_unref (new_pad);

	return (GST_STATE (GST_ELEMENT (video_switch)) == GST_STATE_PLAYING);
}

Again, this only works with certain streams. It worked with two video files that were created in the same way, but it failed with video files from different origin and also failed with two rtsp streams. Maybe the resolution needs to be the same for this to work?

Code is based on this example: