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

Pavel Hofman pavel.hofman at ivitera.com
Fri Dec 8 19:24:11 UTC 2017


Hi Tim,

Dne 8.12.2017 v 19:35 Tim Müller napsal(a):
> 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.

Works great again. In the end I put the check to Message.STREAM_START 
handler and now I get correct audio params any time the stream is 
changed (scheduled in on-about-to -finish).

>> 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.

Thanks, I will keep your insightful information for further 
developement. For now I think the STREAM_START handler will suffice.

> 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.

Will look at that.

> 
> 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).

The audio-pad works just perfect, I always get correct audiodetails of 
the currently played file/stream.

Tim, I very much appreciate your answers. You have pushed me forward a lot!

Regards,

Pavel.


More information about the gstreamer-devel mailing list