Creating New Output Files on Event-Triggered Pipeline Branch Activation in GStreamer

Good day!

The video analytics application includes a gstreamer pipeline with an extra branch that records the current video stream to a file. This branch contains a valve plugin and is triggered by a specific event. I want a new file to be created each time the branch is activated. How can I make sure this happens?

This method is a bit difficult, you’d have to recreate the branch after the valve more or less.

Instead, a easier method is to end with an appsink, and use an non live pipeline for recording, with appsrc in it. You will then be able to send Eos event and receive EOS message back on the recording pipeline. Ensuring your file are terminated and decorated properly.

Thanks for the advice—I got it! But I have one more question: how can I save each video stream to a different file with a unique filename every time?

One possible method is with a counter. You can then create the file name string using g_strdup_printf(). Works like printf but allocates a string for the result.

name = g_strdup_printf("file_%u.ext", counter++);

The filename property on file sink element can then bet set.