Querying caps

Thiago Sousa Santos thiagossantos at gmail.com
Wed Jul 13 13:07:38 UTC 2016


On Wed, Jul 13, 2016 at 9:29 AM, Andrey Nechypurenko <
andreynech at googlemail.com> wrote:

> Hi Sebastian,
>
> > The most reliable way would be to connect to the "notify::caps" signal
> > of the sinkpad of appsink, or to use a pad probe on the sinkpad to
> > intercept the caps event.
>
> I was trying to follow your suggestion with "notify::caps" (please see
> my complete python script below). Unfortunately I am still getting ANY
> as a stringified caps. I am wondering if I am doing something wrong or
> is there a bug or maybe the signal is not an appropriate mechanism in
> this particular case and I should try your second suggestion with the
> probe?
>

You are using a 'query_caps' function that does a caps query on the pad.
This will return all the possible caps that the pad can accept, in this
case (appsink's sinkpad) it will be ANY. You want to use
pad.get_current_caps (
https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstPad.html#gst-pad-get-current-caps)
that will return the currently set caps on that pad.

Regards,


>
> Thank you,
> Andrey.
>
> #!/usr/bin/env python3
>
> import gi
> gi.require_version('Gst', '1.0')
> gi.require_version('Gtk', '3.0')
> from gi.repository import GObject, Gst, Gtk
>
> def notify_caps(pad, args):
>     caps = pad.query_caps(None)
>     print(caps.to_string()) # Always prints ANY <<<<<<
>
> pstr = 'videotestsrc is-live=true ! ' \
>    'video/x-raw, width=640, height=480, framerate=(fraction)30/1 ! ' \
>    'theoraenc ! ' \
>    'rtptheorapay name=payloader ! ' \
>    'appsink name=sink'
>
> GObject.threads_init()
> Gst.init(None)
>
> pipeline = Gst.parse_launch(pstr)
> appsink = pipeline.get_by_name('sink')
> for pad in appsink.sinkpads:
>     pad.connect("notify::caps", notify_caps)
>
> bus = pipeline.get_bus()
> bus.add_signal_watch()
>
> pipeline.set_state(Gst.State.PLAYING)
>
> msg = bus.timed_pop_filtered(
>     Gst.CLOCK_TIME_NONE,
>     Gst.MessageType.ERROR | Gst.MessageType.EOS)
>
> pipeline.set_state(Gst.State.NULL)
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>



-- 
Thiago Sousa Santos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160713/f56843b0/attachment.html>


More information about the gstreamer-devel mailing list