How do I control the writing of files

I run deepstream-app with config:

...
[sink 0]
enable=1
type=3
container=1
codec=1
sync=0
bitrate=2000000
output-file=out.mp4
source-id=0
...

It writes all the time to the file.
If I want to control when I write. Such as when something is detected, it starts writing to the file until it is undetected.
I looked at the Reference Application Configuration. I didn’t find the key related to it.
Thanks.

Hi,
We are checking if we can support this case on DS4.0.

Hi,
We don’t have this implementation in DS4.0. Will evaluate to add it in future releases.

Hi,

This custom logic is specific to the application and not any of the plugins, so you should be able to do it in DS 4.0 itself. Basically, you would need to parse the metadata through a probe in the app and trigger the recording when you observe the required behavior.

Hi,
I see.
I look forward to the future releases.
Thank you.