capture screen on sporadic event
Zoltan Gaal
z.p.gaal.devel at gmail.com
Mon Sep 5 15:39:48 UTC 2016
I'm using gstreamer 1.0 from python.
The gst script is something like:
default_script =
"videotestsrc pattern=smpte is-live=1"
" ! timeoverlay"
" ! video/x-raw,width=640,height=480,framerate=30/1"
" ! x264enc key-int-max=3"
" ! tee name = branch"
# udp sink
"branch."
" ! queue silent = true name = queue_stream "
" ! rtph264pay config-interval = 1 pt = 96"
" ! udpsink host = 192.168.0.12 port = 9000 name = sink_stream"
# app sink for capture
" branch."
" ! queue silent = true max-size-buffers = 1 name = queue_capture "
" ! openh264dec"
" ! jpegenc"
" ! multifilesink location=alma%d.jpg name = capture_sink
Pad-probes are to drop data on the multifilesink branch like this.
First a wait for wait-preroll probe, than an dropp buffer probe is added:
def pad_data_probe_preroll_capture(pad, info, cam):
log.info("preroll capture")
queue = cam._pipeline.get_by_name("queue_capture")
pad = queue.get_static_pad("sink")
pad.add_probe(Gst.PadProbeType.BUFFER, pad_data_probe_capture, cam)
return Gst.PadProbeReturn.REMOVE
def pad_data_probe_capture(pad, info, cam):
if cam._capture_counter.acquire(False):
log.info("enable data, capture")
return Gst.PadProbeReturn.OK
else:
#log.info("info drop: {} {}".format(pad, info.get_buffer().dts))
return Gst.PadProbeReturn.DROP
queue = self._pipeline.get_by_name("capture_sink")
pad = queue.get_static_pad("sink");
pad.add_probe(Gst.PadProbeType.BUFFER | Gst.PadProbeType.BLOCK,
pad_data_probe_preroll_capture, self)
self._pipeline.set_state(Gst.State.PLAYING)
if self._pipeline.get_state(Gst.CLOCK_TIME_NONE) ==
Gst.StateChangeReturn.FAILURE:
raise CameraError("pipeline cannot be prerolled")
It seems to work, but multifilesink captures some old frames instead
of new one (player is at 10s but captures saves frames from the 1st
seconds)
Any suggestions, I've tried to play with the queue parameters but
without any success.
Is it the preferred way to capture screen on events ? As events are
quite frequent (but not time based) disconnect the capture branch
seemed overkill.
Also note that, multifilesink will be replaced by appsink once it is working.
Thanks, gzp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160905/3e33e2f2/attachment-0001.html>
More information about the gstreamer-devel
mailing list