Reading frames one-by-one to python/numpy
hturesson at gmail.com
Mon Dec 7 08:30:54 PST 2015
I would like read individual frames to python/numpy for analysis. That is,
I want call a function that reads and returns 1 frame. I thought I could do
this with appsink, but I have 2 problems. 1) I cannot return a frame from
the callback function 2) It doesn't just read 1 frame.
Simple example that does not do what I want:
from gi.repository import GObject, Gst, Gtk
CLI='filesrc location=testVideo.mp4 ! decodebin ! appsink name=sink'
sample = appsink.emit('pull-sample')
#get the buffer
return False # Here I would like to return the frame
Is it possible to do what I want to do using appsink?
Another strategy I tried is to use fdsink and read the data from that
readfd, writefd = os.pipe()
frame_size_bytes = 460800
CLI='filesrc location=testVideo.mp4 ! decodebin ! fdsink name=sink'
data = os.read(readfd, frame_size_bytes)
This does not work either. The code hang at the data = os.read... line,
maybe trying to play the entire file before moving on.
How can I read only one frame?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gstreamer-devel