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

Tim Müller tim at centricular.com
Fri Dec 8 18:35:53 UTC 2017


On Fri, 2017-12-08 at 19:29 +0100, Pavel Hofman wrote:

> Works like charm, thanks a lot! Please when is the proper time to
> check  the caps of the pad? When pad.get_current_caps() is called too
> early,  the result is None. Is there a specific message in which
> handler to get  the caps the caps?

When you get an ASYNC_DONE message on the pipeline's bus.


> Is there perhaps a way to register a callback and 
> monitor these capabilities for change? I need to send a message
> further down my system when the audio parameters change.

You can connect to the pad's "notify::caps" signal. This is a GObject
feature, and the callback will be called from a streaming thread.

Alternatively you can use the python equivalent of

  gst_element_add_property_deep_notify_watch()

probably something like

  playbin.add_property_deep_notify_watch('caps', True)

then you will get messages on the bus whenever the caps on any pad in
the pipeline change. You will then need to filter for the right pads
and ignore the others.

If you set your own audio-sink and video-sink on playbin(3) you can
also use this API on the sink elements, then you just get notified of
changes in the effective output caps.


> Please what specific pad of the whole pipeline graph does the 
> "get-audio-pad" signal returns? Is it the pad which my audio sink is 
> attached to in playbin by calling
> 
> playbin.set_property('audio-sink', audio_sink) ?

No, it's a pad somewhere inside playbin before input selection takes
place (so you can get the caps/metadata for pads even if the stream is
not currently active/selected).

Cheers
-Tim

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


More information about the gstreamer-devel mailing list