Getting sample rate / sample format/ channels cound of playbin in python

Tim Müller tim at centricular.com
Wed Dec 6 22:59:52 UTC 2017


On Wed, 2017-12-06 at 23:16 +0100, Pavel Hofman wrote:

Hi,

> Please how can rate/channels information be read in python from the 
> playbin element? I found the "get-audio-pad" signal of playbin which 
> likely provides these capabilities but how can I get the pad from
> the  "playbin" element in python (gstreamer 1.0, Gst)?

The signal gives you the pad. From the pad you can query the caps with
something like

 caps = pad.get_current_caps()

and then from the caps you can get the rate/channel fields from the
first caps structure:

 rate = caps[0]['rate']
 chans = caps[0]['channels']

or so.

If you don't actually need to play the file you can also use the
GstDiscoverer API from the pbutils library instead.

With playbin3 this is slightly nicer, you get a STREAM_COLLECTION
message on the bus with the streams and can query the info (caps etc.)
from the stream object instead.

Cheers
 -Tim
-- 
Tim Müller, Centricular Ltd - http://www.centricular.com


More information about the gstreamer-devel mailing list