(Not quite) understanding the appsrc

Florian Echtler floe at butterbrot.org
Mon Feb 8 20:31:03 UTC 2016


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 pipeline */
  gpipeline = gst_pipeline_new ("pipeline");
  appsrc = gst_element_factory_make ("appsrc", "source");

  // create pipeline from string
  const char* pipe_desc = (argc > 1) ? argv[1] : "videoconvert !
fpsdisplaysink sync=false";
  videosink = gst_parse_bin_from_description(pipe_desc,TRUE,NULL);

  /* setup */
  g_object_set (G_OBJECT (appsrc), "caps",
    gst_caps_new_simple ("video/x-raw",
      "format", G_TYPE_STRING, "RGBA",
      "width", G_TYPE_INT, 1920,
      "height", G_TYPE_INT, 1080,
      "framerate", GST_TYPE_FRACTION, 0, 1,
  NULL), NULL);

  gst_bin_add_many (GST_BIN (gpipeline), appsrc, videosink, NULL);
  gst_element_link_many (appsrc, videosink, NULL);

  /* 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);

  /* play */
  gst_element_set_state (gpipeline, GST_STATE_PLAYING);


Afterwards, the mainloop pushes frames to the appsrc with


  gst_app_src_push_buffer(appsrc, gst_buffer_new_wrapped_full(...));
  g_main_context_iteration(g_main_context_default(),FALSE);


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?)

Best, Florian
-- 
SENT FROM MY DEC VT50 TERMINAL

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160208/cccf9ec9/attachment.sig>


More information about the gstreamer-devel mailing list