Querying caps
Andrey Nechypurenko
andreynech at googlemail.com
Wed Jul 13 12:29:29 UTC 2016
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?
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)
More information about the gstreamer-devel
mailing list