Turning sink on and off at runtime

Fredrik Rambris fredrik at rambris.com
Sun Jul 11 12:59:26 UTC 2021


Hello, everyone.
Newbie question coming up.

I'm writing an application to save video from a security camera,
fetched via rtsp and stored in mp4 files. That I got working. My
pipeline is effectively

rtspsrc location=rtsp://hikvision.example.org:554/Streaming/Channels/1
protocols=tcp ! rtph264depay ! h264parse ! splitmuxsink muxer=mp4mux
location=/tmp/garage-%02d.mp4 max-size-bytes=4294967296

Now in another thread I'm listening to the camera's motion detection
events and would like to keep the stream active but sent to null when
there is no motion. When the camera event thread receives motion event
I want the sink to start to write to say /tmp/garage-<current
timestamp>-%02d.mp4 until motion stops when the file should be closed
and the video stream should again be sent to null.

So far I have tried adding both a fakesink and a splitmuxsink to the
pipeline, linking h264parse to fakesink and on motion unlink it, set a
new location to splitmuxsink, send a split-after signal and link it to
h264parse. That kinda worked but the segment index was not reset.

What would be a correct way of switching the file saving on and off?

PS. My application is in Java but examples in C or Python work just as fine.
-- 
Fredrik Rambris <fredrik at rambris.com>


More information about the gstreamer-devel mailing list