FFT, hertz and stream metadata

Tim-Philipp Müller t.i.m at zen.co.uk
Tue May 29 00:39:57 PDT 2012


On Tue, 2012-05-29 at 09:09 +0200, Stefano Parmesan wrote:

Hi Stefano,

> I currently have two pipelines, one playing a simple note, using
> audiotestsrc, and the other playing an mp3. I'm trying to visualize
> the
> spectrum of the input signal (chosen by the user), so I connected to
> the "handoff" signal of an identity element, and I'm playing around
> with the raw buffer received. (..) I need to know the stream bitrate,
> or the time duration of the raw buffer, to convert such frequencies in
> Hertz. Moreover, I need to reconstruct the original buffer, so I need
> to know the stream sample width in order to pack the raw bytes.
> 
> This said, here my questions:
> - how do I know the bitrate, or the milliseconds corresponding to the
> input
> buffer received by an identity element with its handoff event? I tried
> using
> the pipeline clock, but it doesn't seem to fit my needs;
> - how do I know the actual sample width of the stream? I tried using 
> "audiosrc.get_pad("src").get_caps().get_structure(0)" but it gives
> me what 
> I guess are the accepted formats of the pad? I need the actual sample 
> width of the playing pipeline.

You should check the caps on the buffer itself. At least the very first
buffer should have caps set on it. Those caps should have a "rate"
field, and a "width" and "depth" field.

If you query audiosrc's caps, _get_negotiated_caps() might return the
caps actually used.

Cheers
 -Tim




More information about the gstreamer-devel mailing list