pipeline.set_state(gst.STATE_NULL)
return buffer

def main():
    buf = get_frame(sys.argv[1])
with file('frame.png', 'w') as fh:
    fh.write(str(buf))
if __name__ == '__main__':
    main()
How to create video thumbnails with Python and Gstreamer