import gst import tempfile GST_PIPE = ['v4l2src', 'num-buffers=1', 'deinterlace', 'jpegenc'] class Camera(object): def __init__(self): snap_file, self.snap_path = tempfile.mkstemp() # pipe = GST_PIPE + ['filesink location=%s' % self.snap_path] pipe = ['v4l2src', 'jpegenc', 'filesink location=%s' % self.snap_path] self.pipe = gst.parse_launch('!'.join(pipe)) self.bus = self.pipe.get_bus() def Snap(self): """Take a snapshot.""" self.pipe.set_state(gst.STATE_PLAYING) self.bus.poll(gst.MESSAGE_EOS, -1) if __name__ == '__main__': c = Camera() c.Snap() print c.snap_path