Skip to content

Instantly share code, notes, and snippets.

@aborilov
Created February 26, 2015 13:13
Show Gist options
  • Select an option

  • Save aborilov/37bd9bc1ee5b879dac2e to your computer and use it in GitHub Desktop.

Select an option

Save aborilov/37bd9bc1ee5b879dac2e to your computer and use it in GitHub Desktop.
appsink test
import sys
import pygst
pygst.require("0.10")
import gst
import gobject
def main(url):
print url
gobject.threads_init()
command = 'rtspsrc location=%s' % url
command += ' ! appsink name=app enable-last-buffer=true emit-signals=true'
print command
pipeline = gst.parse_launch(command)
app = pipeline.get_by_name('app')
def on_new_buffer(appsink):
buf = appsink.get_property('last-buffer')
print str(buf.data)
app.connect('new-buffer', on_new_buffer)
mainloop = gobject.MainLoop()
pipeline.set_state(gst.STATE_PAUSED)
pipeline.set_state(gst.STATE_PLAYING)
mainloop.run()
if __name__ == "__main__":
main(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment