# About nvstreammux's stream eos event

**URL:** <https://forums.developer.nvidia.com/t/about-nvstreammuxs-stream-eos-event/205099>\
**Category:** DeepStream SDK\
**Tags:** gstreamer, ubuntu\
**Created:** [March 4, 2022, 2:21pm UTC](https://forums.developer.nvidia.com/t/about-nvstreammuxs-stream-eos-event/205099 "2022-03-04T14:21:03Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![471747996](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@471747996](https://forums.developer.nvidia.com/u/471747996)\
**Post date:** [March 4, 2022, 2:21pm UTC](https://forums.developer.nvidia.com/t/about-nvstreammuxs-stream-eos-event/205099/1 "2022-03-04T14:21:03Z")

</div>

Please provide complete information as applicable to your setup.

\*\*• Hardware Platform (Jetson / GPU)\*\*1060  
\*\*• DeepStream Version 6.0  
\*\*• ubuntu1804  
\*\*• TensorRT Version 8.0  
\*\*• NVIDIA GPU Driver Version (valid for GPU only) 510

I write a custom service with deepstream sdk, which recieve the http request to start or stop the request uri’s(may be rtsp rtmp and file:///) anlysis.

and when I request thp http to start one uri stream to be analysising, and after a while, I then request the http to stop the uri stream’s analysis, and then request the http to start and stop the stream uri again and again, it has no problem and work well(note for simple test, all the start and stop requests are on same input stream uri,  
and same nvstreammux’s sink pad index , which is every time request and release nvstreammux’s sink\_1 pad)

but when I request the http to start the stream’s analysising and not stop it from the http request,  
and when the file:///path/to/video reach the end, In the bus callback, I handle the nvstreammux’s stream eos event and in this event I remove this source(and release the nvstreammux’s sink pad sink\_1 with the same way as the http stop used.  
and then I again to request the http to start analysing the stream uri with nvstreammux’s pad sink\_1，the pipline bus callback will recieve the stream eos event as soon as the stream is linked to reqested nvstreammux’s sink\_1 pad, and so it could not be anlysising.

I don’t know why and how to resolve this problem.  
need your help, thank you!

---

<div class="post-metadata">

**Author:** ![kesong](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kesong/32/101255_2.png) [@kesong](https://forums.developer.nvidia.com/u/kesong)\
**Post date:** [March 7, 2022, 12:44pm UTC](https://forums.developer.nvidia.com/t/about-nvstreammuxs-stream-eos-event/205099/3 "2022-03-07T12:44:57Z")

</div>

Maybe the EOS state haven’t been reset when you process the EOS even in the bus callback.

---

<div class="post-metadata">

**Author:** ![471747996](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@471747996](https://forums.developer.nvidia.com/u/471747996)\
**Post date:** [March 7, 2022, 2:11pm UTC](https://forums.developer.nvidia.com/t/about-nvstreammuxs-stream-eos-event/205099/4 "2022-03-07T14:11:46Z")

</div>

hi @kesong:  
Thank you for your reply, could you tell me how to reset the streammux pligin’s eos state in the bus callback?

---

<div class="post-metadata">

**Author:** ![neoragex2002](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/neoragex2002/32/150434_2.png) [@neoragex2002](https://forums.developer.nvidia.com/u/neoragex2002)\
**Post date:** [March 7, 2022, 6:20pm UTC](https://forums.developer.nvidia.com/t/about-nvstreammuxs-stream-eos-event/205099/5 "2022-03-07T18:20:00Z")

</div>

Try set the pipe to `Gst.State.NULL` then reset it to `Gst.State.PLAYING`?

---

<div class="post-metadata">

**Author:** ![471747996](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@471747996](https://forums.developer.nvidia.com/u/471747996)\
**Post date:** [March 8, 2022, 1:10am UTC](https://forums.developer.nvidia.com/t/about-nvstreammuxs-stream-eos-event/205099/6 "2022-03-08T01:10:33Z")

</div>

@neoragex2002 Thank you, but I think this is not a good idea, because set the pipline to NULL then to PLAYTING state will affect other streams analysising!

---

<div class="post-metadata">

**Author:** ![kesong](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kesong/32/101255_2.png) [@kesong](https://forums.developer.nvidia.com/u/kesong)\
**Post date:** [March 8, 2022, 12:04pm UTC](https://forums.developer.nvidia.com/t/about-nvstreammuxs-stream-eos-event/205099/7 "2022-03-08T12:04:09Z")

</div>

How to reproduce the issue?

---

<div class="post-metadata">

**Author:** ![471747996](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@471747996](https://forums.developer.nvidia.com/u/471747996)\
**Post date:** [March 9, 2022, 8:43am UTC](https://forums.developer.nvidia.com/t/about-nvstreammuxs-stream-eos-event/205099/8 "2022-03-09T08:43:26Z")

</div>

@kesong  
you could edit from the runtime\_source\_add\_del sample, like below, input one source and when the buscallback recieve the nvstreammux eos event, delete the source and add the source to the pipline again(pad\_index 0).  
because the nvstreammux is not open source, I don’t know why after the nvstreammux eos event from stream\_id (eg. stream\_id =0), we again to add a source to the pipline use the nvstreammux’s pad\_index=0, it will triggle the eos event as soon as the source is add sccuess to the pipline.

#include \<stdlib.h\>  
#include \<gst/gst.h\>  
#include \<glib.h\>  
#include \<math.h\>  
#include \<gmodule.h\>  
#include \<string.h\>  
#include \<sys/time.h\>  
#include “gstnvdsmeta.h”  
#include “gst-nvmessage.h”  
#include “nvdsmeta.h”  
#include \<cuda\_runtime\_api.h\>

#define MAX\_DISPLAY\_LEN 64

#define PGIE\_CLASS\_ID\_VEHICLE 0  
#define PGIE\_CLASS\_ID\_PERSON 2  
#define SET\_GPU\_ID(object, gpu\_id) g\_object\_set (G\_OBJECT (object), “gpu-id”, gpu\_id, NULL);  
#define SET\_MEMORY(object, mem\_id) g\_object\_set (G\_OBJECT (object), “nvbuf-memory-type”, mem\_id, NULL);  
#define SINK\_ELEMENT “nveglglessink”

GMainLoop _loop = NULL;  
/_ The muxer output resolution must be set if the input streams will be of

- different resolution. The muxer will scale all the input frames to this
- resolution. \*/  
#define MUXER\_OUTPUT\_WIDTH 1920  
#define MUXER\_OUTPUT\_HEIGHT 1080

#define TILED\_OUTPUT\_WIDTH 1280  
#define TILED\_OUTPUT\_HEIGHT 720  
#define GPU\_ID 0  
#define MAX\_NUM\_SOURCES 4  
#define PGIE\_CONFIG\_FILE “dstest\_pgie\_config.txt”  
#define TRACKER\_CONFIG\_FILE “dstest\_tracker\_config.txt”  
#define SGIE1\_CONFIG\_FILE “dstest\_sgie1\_config.txt”  
#define SGIE2\_CONFIG\_FILE “dstest\_sgie2\_config.txt”  
#define SGIE3\_CONFIG\_FILE “dstest\_sgie3\_config.txt”

#define CONFIG\_GPU\_ID “gpu-id”  
#define CONFIG\_GROUP\_TRACKER “tracker”  
#define CONFIG\_GROUP\_TRACKER\_WIDTH “tracker-width”  
#define CONFIG\_GROUP\_TRACKER\_HEIGHT “tracker-height”  
#define CONFIG\_GROUP\_TRACKER\_LL\_CONFIG\_FILE “ll-config-file”  
#define CONFIG\_GROUP\_TRACKER\_LL\_LIB\_FILE “ll-lib-file”  
#define CONFIG\_GROUP\_TRACKER\_ENABLE\_BATCH\_PROCESS “enable-batch-process”

gint g\_num\_sources = 0;  
gint g\_source\_id\_list[MAX\_NUM\_SOURCES];  
gboolean g\_eos\_list[MAX\_NUM\_SOURCES];  
gboolean g\_source\_enabled[MAX\_NUM\_SOURCES];  
GstElement \*\*g\_source\_bin\_list = NULL;  
GMutex eos\_lock;

/\* Assuming Resnet 10 model packaged in DS SDK \*/  
gchar pgie\_classes\_str[4][32] = { “Vehicle”, “TwoWheeler”, “Person”,  
“Roadsign”  
};

GstElement \*pipeline = NULL, \*streammux = NULL, \*sink = NULL, \*pgie = NULL,  
\*sgie1 = NULL, \*sgie2 = NULL, \*sgie3 = NULL,  
\*nvvideoconvert = NULL, \*nvosd = NULL, \*tiler = NULL, \*tracker = NULL;

gchar \*uri = NULL;

static void  
decodebin\_child\_added (GstChildProxy \* child\_proxy, GObject \* object,  
gchar \* name, gpointer user\_data)  
{  
g\_print (“decodebin child added %s\n”, name);  
if (g\_strrstr (name, “decodebin”) == name) {  
g\_signal\_connect (G\_OBJECT (object), “child-added”,  
G\_CALLBACK (decodebin\_child\_added), user\_data);  
}  
int current\_device = -1;  
cudaGetDevice(&current\_device);  
struct cudaDeviceProp prop;  
cudaGetDeviceProperties(&prop, current\_device);

if (g\_strrstr (name, “nvv4l2decoder”) == name) {  
if(prop.integrated) {  
g\_object\_set (object, “enable-max-performance”, TRUE, NULL);  
g\_object\_set (object, “bufapi-version”, TRUE, NULL);  
g\_object\_set (object, “drop-frame-interval”, 0, NULL);  
g\_object\_set (object, “num-extra-surfaces”, 0, NULL);  
} else {  
g\_object\_set (object, “gpu-id”, GPU\_ID, NULL);  
}  
}  
}

static gchar \*  
get\_absolute\_file\_path (gchar \*cfg\_file\_path, gchar \*file\_path)  
{  
gchar abs\_cfg\_path[PATH\_MAX + 1];  
gchar \*abs\_file\_path;  
gchar \*delim;

if (file\_path && file\_path[0] == ‘/’) {  
return file\_path;  
}

if (!realpath (cfg\_file\_path, abs\_cfg\_path)) {  
g\_free (file\_path);  
return NULL;  
}

/\* Return absolute path of config file if file\_path is NULL. \*/  
if (!file\_path) {  
abs\_file\_path = g\_strdup (abs\_cfg\_path);  
return abs\_file\_path;  
}

delim = g\_strrstr (abs\_cfg\_path, “/”);  
\*(delim + 1) = ‘\0’;

abs\_file\_path = g\_strconcat (abs\_cfg\_path, file\_path, NULL);  
g\_free (file\_path);

return abs\_file\_path;  
}

static void  
cb\_newpad (GstElement \* decodebin, GstPad \* pad, gpointer data)  
{  
GstCaps \*caps = gst\_pad\_query\_caps (pad, NULL);  
const GstStructure \*str = gst\_caps\_get\_structure (caps, 0);  
const gchar \*name = gst\_structure\_get\_name (str);

g\_print (“decodebin new pad %s\n”, name);  
if (!strncmp (name, “video”, 5)) {  
gint source\_id = (\*(gint \*) data);  
gchar pad\_name[16] = { 0 };  
GstPad \*sinkpad = NULL;  
g\_snprintf (pad\_name, 15, “sink\_%u”, source\_id);  
sinkpad = gst\_element\_get\_request\_pad (streammux, pad\_name);  
if (gst\_pad\_link (pad, sinkpad) != GST\_PAD\_LINK\_OK) {  
g\_print (“Failed to link decodebin to pipeline\n”);  
} else {  
g\_print (“Decodebin linked to pipeline\n”);  
}  
gst\_object\_unref (sinkpad);  
}  
}

static GstElement \*  
create\_uridecode\_bin (guint index, gchar \* filename)  
{  
GstElement \*bin = NULL;  
gchar bin\_name[16] = { };

g\_print (“creating uridecodebin for [%s]\n”, filename);  
g\_source\_id\_list[index] = index;  
g\_snprintf (bin\_name, 15, “source-bin-%02d”, index);  
bin = gst\_element\_factory\_make (“uridecodebin”, bin\_name);  
g\_object\_set (G\_OBJECT (bin), “uri”, filename, NULL);  
g\_signal\_connect (G\_OBJECT (bin), “pad-added”,  
G\_CALLBACK (cb\_newpad), &g\_source\_id\_list[index]);  
g\_signal\_connect (G\_OBJECT (bin), “child-added”,  
G\_CALLBACK (decodebin\_child\_added), &g\_source\_id\_list[index]);  
g\_source\_enabled[index] = TRUE;

return bin;  
}

static void  
stop\_release\_source (gint source\_id)  
{  
GstStateChangeReturn state\_return;  
gchar pad\_name[16];  
GstPad \*sinkpad = NULL;  
g\_print(“stop release source id %d\n”, source\_id);  
state\_return =  
gst\_element\_set\_state (g\_source\_bin\_list[source\_id], GST\_STATE\_NULL);  
switch (state\_return) {  
case GST\_STATE\_CHANGE\_SUCCESS:  
g\_print (“STATE CHANGE SUCCESS\n\n”);  
g\_snprintf (pad\_name, 15, “sink\_%u”, source\_id);  
sinkpad = gst\_element\_get\_static\_pad (streammux, pad\_name);  
gst\_pad\_send\_event (sinkpad, gst\_event\_new\_flush\_stop (FALSE));  
gst\_element\_release\_request\_pad (streammux, sinkpad);  
g\_print (“STATE CHANGE SUCCESS %p\n\n”, sinkpad);  
gst\_object\_unref (sinkpad);  
gst\_bin\_remove (GST\_BIN (pipeline), g\_source\_bin\_list[source\_id]);  
source\_id–;  
g\_num\_sources–;  
break;  
case GST\_STATE\_CHANGE\_FAILURE:  
g\_print (“STATE CHANGE FAILURE\n\n”);  
break;  
case GST\_STATE\_CHANGE\_ASYNC:  
g\_print (“STATE CHANGE ASYNC\n\n”);  
g\_snprintf (pad\_name, 15, “sink\_%u”, source\_id + 1);  
sinkpad = gst\_element\_get\_static\_pad (streammux, pad\_name);  
gst\_pad\_send\_event (sinkpad, gst\_event\_new\_flush\_stop (FALSE));  
gst\_element\_release\_request\_pad (streammux, sinkpad);  
g\_print (“STATE CHANGE ASYNC %p\n\n”, sinkpad);  
gst\_object\_unref (sinkpad);  
gst\_bin\_remove (GST\_BIN (pipeline), g\_source\_bin\_list[source\_id]);  
source\_id–;  
g\_num\_sources–;  
break;  
case GST\_STATE\_CHANGE\_NO\_PREROLL:  
g\_print (“STATE CHANGE NO PREROLL\n\n”);  
break;  
default:  
break;  
}

}

static gboolean  
delete\_sources (int source\_id)  
{  
stop\_release\_source (source\_id);  
return TRUE;  
}  
static gboolean  
add\_source(int index){  
g\_print(“add\_source id %d\n”, index);  
gint source\_id = index;  
GstElement \*source\_bin;  
GstStateChangeReturn state\_return;  
g\_print (“Calling Start %d \n”, source\_id);  
source\_bin = create\_uridecode\_bin (source\_id, uri);  
if (!source\_bin) {  
g\_printerr (“Failed to create source bin. Exiting.\n”);  
return -1;  
}  
g\_source\_bin\_list[source\_id] = source\_bin;  
gst\_bin\_add (GST\_BIN (pipeline), source\_bin);  
state\_return =  
gst\_element\_set\_state (g\_source\_bin\_list[source\_id], GST\_STATE\_PLAYING);  
switch (state\_return) {  
case GST\_STATE\_CHANGE\_SUCCESS:  
g\_print (“STATE CHANGE SUCCESS\n\n”);  
source\_id++;  
break;  
case GST\_STATE\_CHANGE\_FAILURE:  
g\_print (“STATE CHANGE FAILURE\n\n”);  
break;  
case GST\_STATE\_CHANGE\_ASYNC:  
g\_print (“STATE CHANGE ASYNC\n\n”);  
state\_return =  
gst\_element\_get\_state (g\_source\_bin\_list[source\_id], NULL, NULL,  
GST\_CLOCK\_TIME\_NONE);  
source\_id++;  
break;  
case GST\_STATE\_CHANGE\_NO\_PREROLL:  
g\_print (“STATE CHANGE NO PREROLL\n\n”);  
break;  
default:  
break;  
}  
return TRUE;  
}

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\_WARNING:  
{  
gchar \*debug;  
GError \*error;  
gst\_message\_parse\_warning (msg, &error, &debug);  
g\_printerr (“WARNING from element %s: %s\n”,  
GST\_OBJECT\_NAME (msg-\>src), error-\>message);  
g\_free (debug);  
g\_printerr (“Warning: %s\n”, error-\>message);  
g\_error\_free (error);  
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;  
}  
case GST\_MESSAGE\_ELEMENT:  
{  
if (gst\_nvmessage\_is\_stream\_eos (msg)) {  
guint stream\_id;  
if (gst\_nvmessage\_parse\_stream\_eos (msg, &stream\_id)) {  
g\_print (“Got EOS from stream %d\n”, stream\_id);  
// g\_mutex\_lock (&eos\_lock);  
// g\_eos\_list[stream\_id] = TRUE;  
// g\_mutex\_unlock (&eos\_lock);  
stop\_release\_source(stream\_id);  
add\_source(stream\_id);  
// add\_sources()  
}  
}  
break;  
}  
default:  
break;  
}  
return TRUE;  
}

/\* Tracker config parsing \*/

#define CHECK\_ERROR(error)   
if (error) {   
g\_printerr (“Error while parsing config file: %s\n”, error-\>message);   
goto done;   
}

static gboolean  
set\_tracker\_properties (GstElement \*nvtracker)  
{  
gboolean ret = FALSE;  
GError \*error = NULL;  
gchar \*\*keys = NULL;  
gchar \*\*key = NULL;  
GKeyFile \*key\_file = g\_key\_file\_new ();

if (!g\_key\_file\_load\_from\_file (key\_file, TRACKER\_CONFIG\_FILE, G\_KEY\_FILE\_NONE,  
&error)) {  
g\_printerr (“Failed to load config file: %s\n”, error-\>message);  
return FALSE;  
}

keys = g\_key\_file\_get\_keys (key\_file, CONFIG\_GROUP\_TRACKER, NULL, &error);  
CHECK\_ERROR (error);

for (key = keys; \*key; key++) {  
if (!g\_strcmp0 (\*key, CONFIG\_GROUP\_TRACKER\_WIDTH)) {  
gint width =  
g\_key\_file\_get\_integer (key\_file, CONFIG\_GROUP\_TRACKER,  
CONFIG\_GROUP\_TRACKER\_WIDTH, &error);  
CHECK\_ERROR (error);  
g\_object\_set (G\_OBJECT (nvtracker), “tracker-width”, width, NULL);  
} else if (!g\_strcmp0 (\*key, CONFIG\_GROUP\_TRACKER\_HEIGHT)) {  
gint height =  
g\_key\_file\_get\_integer (key\_file, CONFIG\_GROUP\_TRACKER,  
CONFIG\_GROUP\_TRACKER\_HEIGHT, &error);  
CHECK\_ERROR (error);  
g\_object\_set (G\_OBJECT (nvtracker), “tracker-height”, height, NULL);  
} else if (!g\_strcmp0 (\*key, CONFIG\_GPU\_ID)) {  
guint gpu\_id =  
g\_key\_file\_get\_integer (key\_file, CONFIG\_GROUP\_TRACKER,  
CONFIG\_GPU\_ID, &error);  
CHECK\_ERROR (error);  
g\_object\_set (G\_OBJECT (nvtracker), “gpu\_id”, gpu\_id, NULL);  
} else if (!g\_strcmp0 (_key, CONFIG\_GROUP\_TRACKER\_LL\_CONFIG\_FILE)) {  
char_ ll\_config\_file = get\_absolute\_file\_path (TRACKER\_CONFIG\_FILE,  
g\_key\_file\_get\_string (key\_file,  
CONFIG\_GROUP\_TRACKER,  
CONFIG\_GROUP\_TRACKER\_LL\_CONFIG\_FILE, &error));  
CHECK\_ERROR (error);  
g\_object\_set (G\_OBJECT (nvtracker), “ll-config-file”, ll\_config\_file, NULL);  
} else if (!g\_strcmp0 (_key, CONFIG\_GROUP\_TRACKER\_LL\_LIB\_FILE)) {  
char_ ll\_lib\_file = get\_absolute\_file\_path (TRACKER\_CONFIG\_FILE,  
g\_key\_file\_get\_string (key\_file,  
CONFIG\_GROUP\_TRACKER,  
CONFIG\_GROUP\_TRACKER\_LL\_LIB\_FILE, &error));  
CHECK\_ERROR (error);  
g\_object\_set (G\_OBJECT (nvtracker), “ll-lib-file”, ll\_lib\_file, NULL);  
} else if (!g\_strcmp0 (\*key, CONFIG\_GROUP\_TRACKER\_ENABLE\_BATCH\_PROCESS)) {  
gboolean enable\_batch\_process =  
g\_key\_file\_get\_integer (key\_file, CONFIG\_GROUP\_TRACKER,  
CONFIG\_GROUP\_TRACKER\_ENABLE\_BATCH\_PROCESS, &error);  
CHECK\_ERROR (error);  
g\_object\_set (G\_OBJECT (nvtracker), “enable\_batch\_process”,  
enable\_batch\_process, NULL);  
} else {  
g\_printerr (“Unknown key ‘%s’ for group [%s]”, \*key,  
CONFIG\_GROUP\_TRACKER);  
}  
}

ret = TRUE;  
done:  
if (error) {  
g\_error\_free (error);  
}  
if (keys) {  
g\_strfreev (keys);  
}  
if (!ret) {  
g\_printerr (“%s failed”, **func** );  
}  
return ret;  
}

static GstPadProbeReturn  
osd\_sink\_pad\_buffer\_probe (GstPad \* pad, GstPadProbeInfo \* info, gpointer u\_data)  
{  
GstBuffer \*buf = (GstBuffer \*) info-\>data;  
NvDsBatchMeta \*batch\_meta = gst\_buffer\_get\_nvds\_batch\_meta (buf);  
guint num\_rects = 0;  
NvDsObjectMeta \*obj\_meta = NULL;  
NvDsMetaList \* l\_frame = NULL;  
NvDsMetaList \* l\_obj = NULL;  
NvDsMetaList \* l\_user\_meta = NULL;  
NvDsDisplayMeta \*display\_meta = NULL;  
NvDsFrameMeta _frame\_meta = NULL;  
NvDsUserMeta_ user\_meta = NULL;  
for (l\_frame = batch\_meta-\>frame\_meta\_list; l\_frame != NULL;  
l\_frame = l\_frame-\>next) {  
frame\_meta = (NvDsFrameMeta \*) (l\_frame-\>data);  
// g\_print(“pad\_index %d\n”, frame\_meta-\>pad\_index);  
}  
// g\_print(“end of the post process\n”);  
return GST\_PAD\_PROBE\_OK;  
}

int  
main (int argc, char \*argv)  
{  
GstBus \*bus = NULL;  
guint bus\_watch\_id;  
guint i, num\_sources;  
guint tiler\_rows, tiler\_columns;  
guint pgie\_batch\_size;  
GstElement \*nvtransform;

int current\_device = -1;  
cudaGetDevice(&current\_device);  
struct cudaDeviceProp prop;  
cudaGetDeviceProperties(&prop, current\_device);

/\* Check input arguments \*/  
if (argc != 2) {  
g\_printerr (“Usage: %s \n”, argv[0]);  
return -1;  
}  
num\_sources = argc - 1;

/\* Standard GStreamer initialization \*/  
gst\_init (&argc, &argv);  
loop = g\_main\_loop\_new (NULL, FALSE);

g\_mutex\_init (&eos\_lock);  
/\* Create gstreamer elements _/  
/_ Create Pipeline element that will form a connection of other elements \*/  
pipeline = gst\_pipeline\_new (“dstest-pipeline”);

/\* Use nvinfer to run inferencing on decoder’s output,

- behaviour of inferencing is set through config file \*/  
streammux = gst\_element\_factory\_make (“nvstreammux”, “stream-muxer”);  
g\_object\_set (G\_OBJECT (streammux), “batched-push-timeout”, 25000, NULL);  
g\_object\_set (G\_OBJECT (streammux), “batch-size”, 30, NULL);  
SET\_GPU\_ID (streammux, GPU\_ID);

if (!pipeline || !streammux) {  
g\_printerr (“One element could not be created. Exiting.\n”);  
return -1;  
}  
gst\_bin\_add (GST\_BIN (pipeline), streammux);  
g\_object\_set (G\_OBJECT (streammux), “live-source”, 1, NULL);

g\_source\_bin\_list = g\_malloc0 (sizeof (GstElement \*) \* MAX\_NUM\_SOURCES);  
uri = g\_strdup (argv[1]);  
for (i = 0; i \< num\_sources; i++) {  
GstElement \*source\_bin = create\_uridecode\_bin (i, argv[i + 1]);  
if (!source\_bin) {  
g\_printerr (“Failed to create source bin. Exiting.\n”);  
return -1;  
}  
g\_source\_bin\_list[i] = source\_bin;  
gst\_bin\_add (GST\_BIN (pipeline), source\_bin);  
}

g\_num\_sources = num\_sources;

/\* Use nvinfer to run inferencing on decoder’s output,

- behaviour of inferencing is set through config file  
\*/  
pgie = gst\_element\_factory\_make (“nvinfer”, “primary-nvinference-engine”);

/\* Use nvtiler to stitch o/p from upstream components \*/  
tiler = gst\_element\_factory\_make (“nvmultistreamtiler”, “nvtiler”);

/\* Use convertor to convert from NV12 to RGBA as required by nvosd \*/  
nvvideoconvert =  
gst\_element\_factory\_make (“nvvideoconvert”, “nvvideo-converter”);

if(prop.integrated) {  
nvtransform = gst\_element\_factory\_make (“nvegltransform”, “nvegltransform”);  
}

/\* Create OSD to draw on the converted RGBA buffer \*/  
nvosd = gst\_element\_factory\_make (“nvdsosd”, “nv-onscreendisplay”);

auto osd\_sink\_pad = gst\_element\_get\_static\_pad (nvosd, “sink”);  
if (!osd\_sink\_pad)  
g\_print (“Unable to get sink pad\n”);  
else  
gst\_pad\_add\_probe (osd\_sink\_pad, GST\_PAD\_PROBE\_TYPE\_BUFFER,  
osd\_sink\_pad\_buffer\_probe, (gpointer) osd\_sink\_pad, NULL);  
gst\_object\_unref (osd\_sink\_pad);

tracker = gst\_element\_factory\_make (“nvtracker”, “nvtracker”);

sgie1 = gst\_element\_factory\_make (“nvinfer”, “secondary-nvinference-engine1”);  
sgie2 = gst\_element\_factory\_make (“nvinfer”, “secondary-nvinference-engine2”);  
sgie3 = gst\_element\_factory\_make (“nvinfer”, “secondary-nvinference-engine3”);

/\* Finally render the osd output \*/  
sink = gst\_element\_factory\_make (SINK\_ELEMENT, “nveglglessink”);  
if(prop.integrated) {  
if (!pgie || !sgie1 || !sgie2 || !sgie3 || !tiler || !nvvideoconvert || !nvosd  
|| !sink || !tracker || !nvtransform) {  
g\_printerr (“One element could not be created. Exiting.\n”);  
return -1;  
}  
} else {  
if (!pgie || !sgie1 || !sgie2 || !sgie3 || !tiler || !nvvideoconvert || !nvosd  
|| !sink || !tracker) {  
g\_printerr (“One element could not be created. Exiting.\n”);  
return -1;  
}  
}

g\_object\_set (G\_OBJECT (streammux), “width”, MUXER\_OUTPUT\_WIDTH, “height”,  
MUXER\_OUTPUT\_HEIGHT, NULL);

/\* Set all the necessary properties of the nvinfer element,

- the necessary ones are : \*/  
g\_object\_set (G\_OBJECT (pgie), “config-file-path”, PGIE\_CONFIG\_FILE, NULL);  
g\_object\_set (G\_OBJECT (sgie1), “config-file-path”, SGIE1\_CONFIG\_FILE, NULL);  
g\_object\_set (G\_OBJECT (sgie2), “config-file-path”, SGIE2\_CONFIG\_FILE, NULL);  
g\_object\_set (G\_OBJECT (sgie3), “config-file-path”, SGIE3\_CONFIG\_FILE, NULL);

/\* Set necessary properties of the tracker element. \*/  
if (!set\_tracker\_properties(tracker)) {  
g\_printerr (“Failed to set tracker properties. Exiting.\n”);  
return -1;  
}

/\* Set all the necessary properties of the nvinfer element,

- the necessary ones are : \*/  
g\_object\_get (G\_OBJECT (pgie), “batch-size”, &pgie\_batch\_size, NULL);  
if (pgie\_batch\_size \< MAX\_NUM\_SOURCES) {  
g\_printerr  
(“WARNING: Overriding infer-config batch-size (%d) with number of sources (%d)\n”,  
pgie\_batch\_size, num\_sources);  
g\_object\_set (G\_OBJECT (pgie), “batch-size”, MAX\_NUM\_SOURCES, NULL);  
}

/\* Set GPU ID of elements \*/  
SET\_GPU\_ID (pgie, GPU\_ID);  
SET\_GPU\_ID (sgie1, GPU\_ID);  
SET\_GPU\_ID (sgie2, GPU\_ID);  
SET\_GPU\_ID (sgie3, GPU\_ID);

tiler\_rows = (guint) sqrt (num\_sources);  
tiler\_columns = (guint) ceil (1.0 \* num\_sources / tiler\_rows);  
/\* we set the osd properties here \*/  
g\_object\_set (G\_OBJECT (tiler), “rows”, tiler\_rows, “columns”, tiler\_columns,  
“width”, TILED\_OUTPUT\_WIDTH, “height”, TILED\_OUTPUT\_HEIGHT, NULL);  
SET\_GPU\_ID (tiler, GPU\_ID);  
SET\_GPU\_ID (nvvideoconvert, GPU\_ID);  
SET\_GPU\_ID (nvosd, GPU\_ID);  
if(!prop.integrated) {  
SET\_GPU\_ID (sink, GPU\_ID);  
}

/\* we add a message handler \*/  
bus = gst\_pipeline\_get\_bus (GST\_PIPELINE (pipeline));  
bus\_watch\_id = gst\_bus\_add\_watch (bus, bus\_call, loop);  
gst\_object\_unref (bus);

/\* Set up the pipeline _/  
/_ we add all elements into the pipeline \*/  
gst\_bin\_add\_many (GST\_BIN (pipeline), pgie, tracker, sgie1, sgie2, sgie3,  
tiler, nvvideoconvert, nvosd, sink, NULL);

if(prop.integrated) {  
gst\_bin\_add (GST\_BIN (pipeline), nvtransform);  
}

/\* we link the elements together _/  
/_ file-source → h264-parser → nvh264-decoder →

- nvinfer → nvvideoconvert → nvosd → video-renderer \*/  
if(prop.integrated) {  
if (!gst\_element\_link\_many (streammux, pgie, tracker, sgie1, sgie2, sgie3,  
tiler, nvvideoconvert, nvosd, nvtransform, sink, NULL)) {  
g\_printerr (“Elements could not be linked. Exiting.\n”);  
return -1;  
}  
} else {  
if (!gst\_element\_link\_many (streammux, pgie, tracker, sgie1, sgie2, sgie3,  
tiler, nvvideoconvert, nvosd, sink, NULL)) {  
g\_printerr (“Elements could not be linked. Exiting.\n”);  
return -1;  
}  
}

g\_object\_set (G\_OBJECT (sink), “sync”, FALSE, “qos”, FALSE, NULL);

gst\_element\_set\_state (pipeline, GST\_STATE\_PAUSED);

/\* Set the pipeline to “playing” state \*/  
g\_print (“Now playing: %s\n”, argv[1]);  
if (gst\_element\_set\_state (pipeline,  
GST\_STATE\_PLAYING) == GST\_STATE\_CHANGE\_FAILURE) {  
g\_printerr (“Failed to set pipeline to playing. Exiting.\n”);  
return -1;  
}  
//GST\_DEBUG\_BIN\_TO\_DOT\_FILE\_WITH\_TS (GST\_BIN (pipeline), GST\_DEBUG\_GRAPH\_SHOW\_ALL, “ds-app-playing”);

/\* Wait till pipeline encounters an error or EOS \*/  
g\_print (“Running…\n”);  
// g\_timeout\_add\_seconds (10, add\_sources, (gpointer) g\_source\_bin\_list);  
g\_main\_loop\_run (loop);

/\* Out of the main loop, clean up nicely \*/  
g\_print (“Returned, stopping playback\n”);  
gst\_element\_set\_state (pipeline, GST\_STATE\_NULL);  
g\_print (“Deleting pipeline\n”);  
gst\_object\_unref (GST\_OBJECT (pipeline));  
g\_source\_remove (bus\_watch\_id);  
g\_main\_loop\_unref (loop);  
g\_free (g\_source\_bin\_list);  
g\_free (uri);  
g\_mutex\_clear (&eos\_lock);  
return 0;  
}

---

<div class="post-metadata">

**Author:** ![kesong](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kesong/32/101255_2.png) [@kesong](https://forums.developer.nvidia.com/u/kesong)\
**Post date:** [July 1, 2022, 9:47am UTC](https://forums.developer.nvidia.com/t/about-nvstreammuxs-stream-eos-event/205099/9 "2022-07-01T09:47:25Z")

</div>

Sorry for later response. Can you have a try with latest DS 6.1 release?

---

<div class="post-metadata">

**Author:** ![xiaoxinggui](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@xiaoxinggui](https://forums.developer.nvidia.com/u/xiaoxinggui)\
**Post date:** [September 23, 2022, 6:49am UTC](https://forums.developer.nvidia.com/t/about-nvstreammuxs-stream-eos-event/205099/10 "2022-09-23T06:49:01Z")

</div>

I had the same problem！！！how to resolve it?

---

<div class="post-metadata">

**Author:** ![yingliu](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/yingliu/32/136703_2.png) [@yingliu](https://forums.developer.nvidia.com/u/yingliu)\
**Post date:** [September 27, 2022, 6:17am UTC](https://forums.developer.nvidia.com/t/about-nvstreammuxs-stream-eos-event/205099/11 "2022-09-27T06:17:07Z")

</div>

Can you help create a new topic with your own’s environment and logs in details? That’s will be easy for the discussion and tracking, thank you.

---

<div class="post-metadata">

**Author:** ![yingliu](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/yingliu/32/136703_2.png) [@yingliu](https://forums.developer.nvidia.com/u/yingliu)\
**Post date:** [October 11, 2022, 3:24am UTC](https://forums.developer.nvidia.com/t/about-nvstreammuxs-stream-eos-event/205099/12 "2022-10-11T03:24:15Z")

</div>

Closed on October 11, 2022, 3:24am UTC


