I'm trying to setup a GStreamer appsrc as a video source, but even a trivial program does not work at all and produces random crashes or hangings so far. Could you please help to spot the problem? Minimal crashing code:
import gst, gtk
def need_data(src, need_bytes):
src.emit("push-buffer", gst.Buffer(" "*need_bytes))
def on_message(bus, msg):
print "on_message", msg
pipeline = gst.parse_launch("appsrc name=src ! fakesink")
src = pipeline.get_by_name("src")
src.connect("need-data", need_data)
src.set_property("blocksize", 640*480*3)
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", on_message)
pipeline.set_state(gst.STATE_PLAYING)
gtk.main()
The solution appeared to be quite simple. At some point program was lucky to spit Fatal Python error: GC object already tracked
message, and it became pretty clear: a call to gobject.threads_init()
was missing. Adding this call to the beginning of the program fixed the issue.