Motion detection

Nicolas Dufresne nicolas at ndufresne.ca
Wed Sep 6 01:40:14 UTC 2017


Le mardi 05 septembre 2017 à 11:20 +0000, luke a écrit :
> I would like to use gstreamer through the CLI to store a video when
> motion is detected but I don't know how to configure the sink to
> store the images only if a motion is detected. Something like:
> 
> gst-launch-1.0 v4l2src ! videoconvert ! motioncells ! ??? 
> 
> I don't care about the cells themselves. Actually, I would rather not
> have them rendered on the stored file.

You'll need to program something, gst-launch-1.0 does not have support
for changing the stream upon a message. Programatically, you'll need to
watch for element messages on the bus. The simplest is to use a tee,
when there is activity, create a new branch on the tee. When activity
ends, disconnect the branch, push an EOS and discard.

regards,
Nicolas

p.s. An example monitor pipeline, with a statically connect recording
branch for demonstration:

gst-launch-1.0 -em pipeline. \( latency=200000000 v4l2src ! tee name=t
! queue ! jpegdec ! video/x-raw,framerate=15/1,width=352 ! videoconvert
! queue ! motioncells display=1 ! queue !  glimagesink t. ! queue !
qtmux ! filesink location=test.mov \)


More information about the gstreamer-devel mailing list