How to save files on detections only or stop a sink receiving frames until a detection is made?

I’m wondering how to construct a deepstream pipeline where a file is written based on an object detection.

For example a scenario like this:

When a person is detected, start writing the stream to a file for 30 seconds then stop. When a person detection event occurs again start writing another file.

Such that you end up with a whole series of 30 second video clips showing all the person detection’s.

There are allot of potential use-cases for deepstream and edge devices where the video stream is only sent to the cloud on a positive detection/event but I can’t see how to do this as all the samples are designed around constant streaming right through the pipeline.

Another potential example would be with a jetson nano setup with a camera and watching for birds. When a bird is detected it starts streaming the video to the cloud - instead of all the examples here which would just fulltime stream regardless of whether any detection exist and using up bandwidth.

Just after some ideas to continue my research? ;-)

When a person is detected, start writing the stream to a file for 30 seconds then stop. When a person detection event occurs again start writing another file.

– Pelase check dsexample gst-plugin, You can get every frame raw data and inference result in metadata.

There are allot of potential use-cases for deepstream and edge devices where the video stream is only sent to the cloud on a positive detection/event but I can’t see how to do this as all the samples are designed around constant streaming right through the pipeline.

– We have opensource “gst-nvmsgbroker” “gst-nvmsgconv” You can modify them according to your requirement.

You can also use GST_PAD_PROBE_DROP macro to drop the buffer in the attached probe.
Refer to https://gstreamer.freedesktop.org/documentation/application-development/advanced/pipeline-manipulation.html?gi-language=c for the example

static GstPadProbeReturn
event_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
    return GST_PAD_PROBE_DROP;
}

Have tried the GST_PAD_PROBE_DROP option and it works well when the sink is displaying on a screen.