How to use deepstream to call multiple cameras, so that one camera is fine, but multiple cameras will be wrong

#this is my code

#include <gst/gst.h>
#define MUXER_BATCH_TIMEOUT_USEC 400000
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print (“End of stream\n”);
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *error;
gst_message_parse_error (msg, &error, &debug);
g_printerr (“ERROR from element %s: %s\n”,
GST_OBJECT_NAME (msg->src), error->message);
if (debug)
g_printerr (“Error details: %s\n”, debug);
g_free (debug);
g_error_free (error);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}

int main(int argc, char *argv)
{

guint bus_watch_id;
GMainLoop *loop = NULL;
GstElement *bin, *pipeline, *source, *convert1,*filter1,*convert2,*filter2,*convert3, *muxsink,*infer,*tiler,*transform,*sink,*source1,*filter_1, *filter_2, *convert_1,*source_fake,
*sink_fake ,*queue1;
GstBus *bus;
GstCaps *caps1,*caps2,*caps_1,*caps_2;
GstStateChangeReturn ret;

gst_init(&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);

pipeline = gst_pipeline_new(“wtf-pipeline”);
source = gst_element_factory_make(“v4l2src”, “source”);
filter1 = gst_element_factory_make(“capsfilter”, “filter”);
filter2 = gst_element_factory_make(“capsfilter”, “filter2”);
convert1 = gst_element_factory_make(“nvvidconv”, “convert”);

convert3 = gst_element_factory_make(“nvvideoconvert”, “convert3”);
muxsink = gst_element_factory_make(“nvstreammux”, “muxsink”);
transform = gst_element_factory_make(“nvegltransform”, “transform”);
sink = gst_element_factory_make(“nveglglessink”, “sink”);
tiler = gst_element_factory_make (“nvmultistreamtiler”, “nvtiler”);

//gst_bin_add (GST_BIN (pipeline), bin);

source1 = gst_element_factory_make(“v4l2src”, “source1”);
filter_1 = gst_element_factory_make(“capsfilter”, “filter-1”);
filter_2 = gst_element_factory_make(“capsfilter”, “filter-2”);
convert_1 = gst_element_factory_make(“nvvidconv”, “convert-1”);

queue1 = gst_element_factory_make (“queue”, “queue1”);

gst_bin_add (GST_BIN (pipeline), source1);
gst_bin_add (GST_BIN (pipeline), filter_1);
gst_bin_add (GST_BIN (pipeline), filter_2);
gst_bin_add (GST_BIN (pipeline), convert_1);

gst_bin_add (GST_BIN (pipeline), tiler);

if (!pipeline || !source
|| !filter1 || !filter2 || !convert1||!convert3||!muxsink ||!transform||!sink||!tiler
)
{
g_printerr (“One element could not be created. Exiting.\n”);
return -1;
}

gst_bin_add_many(GST_BIN(pipeline), source,filter1,convert1,filter2, muxsink,queue1,convert3,transform,sink, NULL);

if (!gst_element_link_many(source,filter1,convert1,filter2,NULL))
{
g_printerr (“Elements could not be linked: 1. Exiting.\n”);
return -1;
}

if (!gst_element_link_many(source1,filter_1,convert_1,filter_2,NULL))
{
g_printerr (“Elements could not be linked: 2. Exiting.\n”);
return -1;
}

caps1 = gst_caps_new_simple(“video/x-raw”,
“width”, G_TYPE_INT, 1920,
“height”, G_TYPE_INT, 1080,
“framerate”, GST_TYPE_FRACTION, 30,
1, NULL);

caps2 = gst_caps_new_simple(“video/x-raw(memory:NVMM)”,
“format”,G_TYPE_STRING,“(string)NV12”,
“width”, G_TYPE_INT, 960,
“height”, G_TYPE_INT, 540,
“framerate”, GST_TYPE_FRACTION, 30,
1, NULL);
///////
caps_1 = gst_caps_new_simple(“video/x-raw”,
“width”, G_TYPE_INT, 1920,
“height”, G_TYPE_INT, 1080,
“framerate”, GST_TYPE_FRACTION, 30,
1, NULL);

caps_2 = gst_caps_new_simple(“video/x-raw(memory:NVMM)”,
“format”,G_TYPE_STRING,“(string)NV12”,
“width”, G_TYPE_INT, 960,
“height”, G_TYPE_INT, 540,
“framerate”, GST_TYPE_FRACTION, 30,
1, NULL);

g_object_set(G_OBJECT(source), “device”,“/dev/video0”, NULL);
g_object_set(G_OBJECT(source1), “device”,“/dev/video2”, NULL);

g_object_set(G_OBJECT(filter1), “caps”, caps1, NULL);
g_object_set(G_OBJECT(filter2), “caps”, caps2, NULL);

g_object_set(G_OBJECT(filter_1), “caps”, caps_1, NULL);
g_object_set(G_OBJECT(filter_2), “caps”, caps_2, NULL);

g_object_set(G_OBJECT(muxsink),“width”,960,“height”,540, “batch-size”, 4, “live-source”, 1, “batched-push-timeout”, MUXER_BATCH_TIMEOUT_USEC, NULL);
g_object_set (G_OBJECT (tiler), “rows”, 2, “columns”, 2,
“width”, 1920, “height”,1080, NULL);

GstPad *source_pad = gst_element_get_static_pad(filter2, “src”);
guint i=0;
gchar pad_name[16]= {};
g_snprintf(pad_name, 15, “sink_%u”,i);
GstPad *sink_pad = gst_element_get_request_pad(muxsink,pad_name);
gst_pad_link(source_pad, sink_pad);

GstPad *source_pad_1 = gst_element_get_static_pad(filter_2, “src”);
guint k=1;
gchar pad_name_1[16]= {};
g_snprintf(pad_name_1, 15, “sink_%u”,k);
GstPad *sink_pad_1 = gst_element_get_request_pad(muxsink,pad_name_1);
gst_pad_link(source_pad_1, source_pad_1);

gst_element_link_many(muxsink,queue1,tiler,convert3,transform,sink,NULL);
gst_element_set_state(pipeline, GST_STATE_PLAYING);

bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);

g_main_loop_run (loop);

gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}

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

Can you elaborate on the issue in detail? What kind of error are you facing?

Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• 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)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)
• The pipeline being used

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