Created
September 17, 2014 19:07
-
-
Save jampekka/ec4a3f3a3748fd2a281d to your computer and use it in GitHub Desktop.
Gstreamer 1.0 v4l2src with Python halts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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