GStreamer RTSP Client increase memory usage gradually in Jetson TX2

Hello.

I ran following code for 3 hours.
gstreamer_client.c (4.3 KB)

So memory usage increased by 36MB.

My problem is that memory keeps increasing gradually.

How can I solve this problem?

I use libgstreamer 1.14.5, jetpack 4.2.1, L4T R32.2

I can see following log…

NvRmPrivFlush: NvRmChannelSubmit failed (err = 196623, SyncPointIdx = 48, SyncPointValue = 0)

Hi,
Please try nvv4l2decoder. We are deprecating omx plugins. Please use v4l2 plugins.

Do you have any example code?

nvv4l2decoder and omxh264dec is different. So my code doesn’t work.

I change the code.

source = gst_element_factory_make (“rtspsrc”, “rtsp-source”);
queue1 = gst_element_factory_make (“queue”, “front-queue”);
depay = gst_element_factory_make (“rtph264depay”, “rtp-depay”);
parse = gst_element_factory_make (“h264parse”, “parser”);
decoder = gst_element_factory_make (“nvv4l2decoder”, “decoder”);
sink = gst_element_factory_make (“appsink”, “sink”);

width and height is ok. But size is only 976… too small.
How can i fix?

GstFlowReturn new_sample0(GstAppSink *appsink, gpointer data)
{

GstSample *sample = gst_app_sink_pull_sample(GST_APP_SINK(appsink));

if (sample != NULL)
{
            GstCaps *caps = gst_sample_get_caps(sample);
	GstBuffer *buffer = gst_sample_get_buffer(sample);

	int width, height;
	GstStructure* structure = gst_caps_get_structure (caps, 0);
	gst_structure_get_int(structure, "height", &height);
	gst_structure_get_int(structure, "width", &width);
	int size = gst_buffer_get_size(buffer);

           printf("%d %d %d\n", width, height, size);

nvv4l2decoder may output in NVMM memory which may not be suitable for your cpu application.
Try adding nvvidconv after nvv4l2decoder. In case it wouldn’t work out, you might have to specify caps video/x-raw as nvvidconv src caps.

1 Like

Thank you for your guidance.

I modified the code as follows and it works fine.
Now I watching if the memory usage goes up.
Thank for all.

pipeline = gst_pipeline_new ("player");
source   = gst_element_factory_make ("rtspsrc",       "rtsp-source");
queue1   = gst_element_factory_make ("queue",         "front-queue");
depay    = gst_element_factory_make ("rtph264depay",  "rtp-depay");
parse    = gst_element_factory_make ("h264parse",     "parser");
decoder  = gst_element_factory_make ("nvv4l2decoder",    "decoder"); 
conv = gst_element_factory_make("nvvidconv", "conv"); 
sink     = gst_element_factory_make ("appsink",   "sink");
filter1 = gst_element_factory_make ("capsfilter", "video_filter1");
filter2 = gst_element_factory_make ("capsfilter", "video_filter2");

if (!pipeline || !source || !queue1 || !depay || !parse || !decoder || !filter1 ||!conv || !filter2 || !sink ) {
    g_printerr ("One element could not be created. Exiting.\n");
    return 1;
}

/* Set up the pipeline */
GstCaps    *caps1, *caps2;
caps1 = gst_caps_from_string ("video/x-raw(memory:NVMM)"); 
caps2 = gst_caps_from_string ("video/x-raw"); 
g_object_set (G_OBJECT (filter1), "caps", caps1, NULL);
g_object_set (G_OBJECT (filter2), "caps", caps2, NULL);
gst_caps_unref (caps1);
gst_caps_unref (caps2);


gst_bin_add_many (GST_BIN (pipeline), source, queue1, depay, parse, decoder, conv, filter1, filter2, sink, NULL);

gst_element_link_many (queue1, depay, parse, decoder, filter1, conv, filter2, sink, NULL);

Hi,

I changed the decoder from omxh264dec to nvv4l2decoder. So it works well.

I run the program and check the memory usage with tegrastats.

Is there a test method to effectively check memory usage and find the cause of memory growth?

Hi,
You may try Linux tools such as
https://www.thegeekdiary.com/understanding-proc-meminfo-file-analyzing-memory-utilization-in-linux/
https://linux.die.net/man/8/vmstat

Hi,

I tested program several times and found it. The memory used by GStreamer rises very slowly.

If RTSP IP Camera is input source, does GStreamer use buffering internally, so does the memory rise to a certain level and keep it constant?

Is it not necessary to change the RTSP-related settings to use the buffer up to a certain size?

Thank you for your help : )

Hi

the problem is solved.
It was a problem not related to RTSP setting.

Thanks.

1 Like