When I run this, I get the cam snapshot on the file:
gst-launch-0.10 v4l2src num-buffers=1 ! jpegenc ! filesink location=pic.jpg
I tried to put that in Python and instead of the pic I get an empty file. Can someone tell where the mistake is? It's a very simple code that should do a very simple task. Also, I don't want to use gst.parse_launch(), I need to understand the construction of pipelines in Python.
import sys, os
import pygtk, gtk, gobject
import pygst
pygst.require("0.10")
import gst
class GTK_Main:
def __init__(self):
self.player = gst.Pipeline("player")
source = gst.element_factory_make("v4l2src", "video-source")
source.set_property("num-buffers", 1)
conv = gst.element_factory_make("jpegenc", "jpeg-converter")
sink = gst.element_factory_make("filesink", None)
sink.set_property("location", "pic.jpg")
self.player.add(source, conv, sink)
gst.element_link_many(source, conv, sink)
self.player.set_state(gst.STATE_PLAYING)
GTK_Main()
gtk.gdk.threads_init()