How to transfer GstBuffer from one pipeline to other pipeline

Andy Devar andy.devar at
Sun Nov 29 22:06:31 UTC 2020


how to do this correctly? I'm referring to Anton's suggestion to use

As soon as I copy the buffer (see example below), I get a memory leak
(megabytes per second, so I think the buffer won't be disposed).

If I don't copy the buffer, I get warnings - probably because the copied
sample references the buffer of the sample received from appsink:
"free_priv_data: object finalizing but still has 1 parents

gstreamer version: 1.18.1 x64 msvc

g_signal_connect(videosink, "new-sample",
G_CALLBACK(on_new_sample_from_appsink), data);

on_new_sample_from_appsink(GstElement * elt, ProgramData * data)
/* get the sample from appsink */
GstSample *sample_in;
sample_in = gst_app_sink_pull_sample(GST_APP_SINK(elt));

// Copy the sample.
GstSample* sample_out = gst_sample_copy(sample_in);
// Now, the buffer of sample_out is a reference to the buffer of sample_in.

// Copy the buffer of sample_in and set it as buffer of sample_out
GstBuffer *buffer_in = gst_sample_get_buffer(sample_in);
GstBuffer *buffer_out = gst_buffer_copy_deep(buffer_in);
gst_sample_set_buffer(sample_out, buffer_out);

// Push sample_out to appsource
GstElement* appsource = gst_bin_get_by_name(GST_BIN(data->targetpipeline),
gst_app_src_push_sample(GST_APP_SRC(appsource), sample_out);


return GST_FLOW_OK;



Am Mo., 21. Sept. 2020 um 14:23 Uhr schrieb shiva.mudugal <
shiva.mudugal at>:

> Hello Anton,
> Thanks for your response. In understand you point, but is there a way to do
> this without creating the deep copy  from pipeline1 to pipeline2 ?
> My intention is to avoid deep copy from pipeline1 to pipeline2. Can we just
> increase the reference count of the buffer in the appsink callback of
> pipeline1 to then apsrc_push to pipeline2 ?
> -Regards,
> Shiva
> --
> Sent from:
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gstreamer-devel mailing list