Timestamp based extraction of audio data from GstAdapter

Sebastian Dröge sebastian at centricular.com
Thu Apr 13 12:51:00 UTC 2017


On Thu, 2017-04-13 at 02:39 -0700, dingoegret wrote:
> Is there a plugin that would allow me to pull 100ms pts of audio
> every 100ms of real time? I was looking at audiorate but nothing I've
> tried accomplished what I wanted.

You probably want to look at the new audiobuffersplit element:
https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/gst/audiobuffersplit

It does exactly that. You configure an output buffer size and it
outputs exactly that many samples, while making sure that timestamps
are correctly handled.

>  My program is simple filesrc to appsink where I have set 'new-
> sample' signal' with the following callback 
> 
> static void new_sample(GstElement *sink) { 
>     GstSample *sample; 
>     g_signal_emit_by_name(sink, "pull-sample", &sample); 
> 
>     if(sample) { 
>         GstBuffer* buffer = gst_sample_get_buffer(sample); 
>         gst_adapter_push(adapter, buffer); 
>     } 
>
You can't pass the buffer from the sample to the adapter like that as
you don't own the reference to the buffer. You have to ref() first.

For getting timestamps, GstAdapter has the gst_adapter_prev_pts() API,
which also gives you the distance to where this timestamp was observed.

-- 
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: 963 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20170413/93d1c322/attachment.sig>


More information about the gstreamer-devel mailing list