1

I'm using gstreamer's appsink and I find that its cpu load is very high when I set drop=true

the following pipeline works:

gst-launch-1.0 -v rtspsrc location="rtsp://somelink" latency=300 ! rtph265depay ! h265parse ! avdec_h265 ! videoconvert !  appsink caps="video/x-raw,format=BGR"

Please note that appsink is used.

But if I add drop=true to appsink, the cpu load turn to be very high (as high as 100% for 1 cpu core)

I checked the appsink's source code: https://git.launchpad.net/ubuntu/+source/gst-plugins-base1.0/tree/gst-libs/gst/app/gstappsink.c

    if (priv->drop) {
      GstMiniObject *old;

      /* we need to drop the oldest buffer/list and try again */
      if ((old = dequeue_buffer (appsink))) {
        GST_DEBUG_OBJECT (appsink, "dropping old buffer/list %p", old);
        gst_mini_object_unref (old);
      }
    }

then the source code of dequeue_buffer:

static GstMiniObject *
dequeue_buffer (GstAppSink * appsink)
{
  GstMiniObject *obj;

  do {
    obj = dequeue_object (appsink);

    if (GST_IS_BUFFER (obj) || GST_IS_BUFFER_LIST (obj)) {
      break;
    }

    gst_mini_object_unref (obj);
  } while (TRUE);

  return obj;
}

Please note that there is a while (TRUE) in the function and I really suspect that it causes the high cpu usage, but I didn't find a way to debug it.

Any one has the same issue and what's the workaround?

Felix F Xu
  • 125
  • 7
  • Since you did not define a `max-buffers` value I have some doubts the drop property value should have any effect at all. – Florian Zwoch Jul 11 '22 at 15:53
  • @FlorianZwoch I have verified again that if I don't define `max-buffers=1`, the memory usage will increase very fast. But as to CPU load, `drop=true` will increase cpu load regardless of max-buffers value. – Felix F Xu Jul 12 '22 at 03:00

0 Answers0