Extracing data from samples

krrr kosareka at gmail.com
Tue Dec 11 17:57:28 UTC 2018


I found this answer:
http://gstreamer-devel.966125.n4.nabble.com/Convertion-of-GstBuffer-to-PCM-audio-data-td4676543.html
, and this is very close to my question, however, I'm still wondering if the
same applies to mp3 files. I have to calculate the Fourier transform of the
songs, that's the reason for the need of getting the songs/samples as an
array of numbers. I tried the get_buffer() method, mapped it into a
MapInfoData object and saved the samples, and this time I got an array with
length of 383*4608 for my 10 second mp3 file, where 383 is the number of
samples and 4608 is the size of buffer. A saved each element for sample data
to an 8-bit unsigned int for the test, but   this
<https://superuser.com/a/1173507>   answer says that bit depth may alter for
each sample in the case of mp3. Here are the relevant parts from my
code:GstFlowReturn sample_arrived(GstAppSink *appsink, AudioStreamer
*audio_streamer){    if (!gst_app_sink_is_eos(appsink))    {       
GstSample *sample = gst_app_sink_pull_sample(appsink);       
//assert(sample);        audio_streamer->_samples.push(sample);       
GstBuffer *buffer = gst_sample_get_buffer(sample);        GstMapInfo info;       
if (gst_buffer_map(buffer, &info, GST_MAP_READ))        {           for (
guint i = 0; i < info.size; ++i)           //g_print("%u\n", info.data[i]);          
audio_streamer->_tmp_samples.push(info.data[i]); //type of _tmp_samples:
std::queue        }        gst_buffer_unmap (buffer, &info);       
gst_sample_unref(sample);    }    return GST_FLOW_OK;} Is this the right way
for doing this? 



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20181211/26840e7d/attachment.html>


More information about the gstreamer-devel mailing list