Reputation: 81
I have a simple pipeline set up as below with Gstreamer 1.0. When I try to create pull samples from the appsink, the code stalls at "sample = appsink.emit('pull-sample')" . The weird part is that if I remove that line, the code works as expected, continually printing "trying to pull sample". I get the same stall if I try to skip the first 100 samples or so as well as changing the properties on the appsink. Anyone have an idea of what's going on?
gst-launch-1.0 v4l2src device="/dev/video0" ! videorate ! video/x raw,height=480,width=640,framerate=15/1 ! appsink
def createASink():
asink = Gst.ElementFactory.make('appsink', 'asink')
asink.set_property('sync', False)
asink.set_property('emit-signals', True)
asink.set_property('drop', True)
asink.connect('new-sample', new_sample)
return asink
def new_sample(appsink):
print "Trying to pull sample"
sample = appsink.emit('pull-sample')
return False
Upvotes: 4
Views: 2848
Reputation: 81
So this is a hack workaround but it still works. If someone knows a better solution please let me know.
I can use a filesink to output the byte array and then read from that continuously. I use the multiprocessing module in python to run gstreamer and my consumer at the same time.
def consumeStream():
fp = "gst_data"
with open(fp, "r+b") as data_file:
data_file.truncate()
while True:
where = data_file.tell()
line = data_file.readline()
if not line:
time.sleep(.05)
data_file.seek(where)
else:
data_file.truncate()
print "Got data"
Upvotes: 1