Skip to content

Instantly share code, notes, and snippets.

@jampekka
Created Sep 17, 2014
Embed
What would you like to do?
Gstreamer 1.0 v4l2src with Python halts
# PyGST with Gst 0.10 works fine
import gst
pipe = gst.parse_launch("""v4l2src device=/dev/video0 !
appsink sync=false max-buffers=1 drop=true name=sink emit-signals=true""")
sink = pipe.get_by_name('sink')
pipe.set_state(gst.STATE_PLAYING)
while True:
print "Getting a buffer"
buf = sink.emit('pull-buffer')
print len(buf)
# gi with Gst 1.0 freezes after two or so frames
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
# This doesn't seem to make any difference
#GObject.threads_init()
Gst.init(None)
# This works
#pipe = Gst.parse_launch("""videotestsrc !
# appsink sync=false max-buffers=1 drop=true name=sink emit-signals=true""")
# This halts after a few frames
pipe = Gst.parse_launch("""v4l2src device=/dev/video0 !
appsink sync=false max-buffers=1 drop=true name=sink emit-signals=true""")
sink = pipe.get_by_name('sink')
pipe.set_state(Gst.State.PLAYING)
while True:
print "Getting a sample"
sample = sink.emit('pull-sample')
print sample.get_buffer().get_size()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment