(Not quite) understanding the appsrc

Sebastian Dröge sebastian at centricular.com
Tue Feb 16 08:08:12 UTC 2016


On Mo, 2016-02-08 at 21:31 +0100, Florian Echtler wrote:
> Hi everyone,
> 
> I have a custom application that pulls frames from an Intel Realsense
> camera with 30 FPS and pushes them to an appsrc. Everything works as
> intended, but there seems to be a significant amount of lag that
> increases with longer runtime. The setup looks like this:
> [...]
>   /* setup appsrc */
>   g_object_set (G_OBJECT (appsrc),
>     "stream-type", 0, // GST_APP_STREAM_TYPE_STREAM
>     "format", GST_FORMAT_TIME,
>     "is-live", TRUE,
>     "min-latency", 0,
>     "max-latency", gst_util_uint64_scale_int (1, GST_SECOND, 30),
>     "do-timestamp", TRUE,
>   NULL);
> 
> As mentioned above, this works as intended. However, the whole
> program leaks memory like crazy (the buffers _are_ freed correctly,
> but not as fast as new ones are created) and the output starts
> lagging more and more badly. AFAICT the appsrc can be told to discard
> old buffers to keep up, but seems to be queueing them instead.
> 
> Would be grateful for any hints on how to fix this (maybe using
> min-latency and max-latency?)

The latency settings you have there don't make much sense and you
should better keep the defaults :)

So the question here is why and where buffers are piling up. appsrc
only should buffer up to a frame or 200kb (whichever comes first) of
buffers, so in your case one frame. You can check that with the
"current-level-bytes" property. However it only does that if "block" is
set to TRUE (the default is FALSE), otherwise it assumes that you
listen to the "enough-data" signal and stop pushing data until it
reports "need-data" again.

So try setting "block" to TRUE and see if that helps in your case.

-- 
Sebastian Dröge, Centricular Ltd · http://www.centricular.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 949 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160216/1a225796/attachment.sig>


More information about the gstreamer-devel mailing list