How to get last 30 seconds of live streaming?

Currently when stream starts, I start its recording in append mode and I have known that we can only play video after its recording is stopped.

I know there is a option to record in segments but I don’t want to do that. I want the recorded video in a single file.

So, is there a way to get only last 30 seconds of video?
OR

To start 2 recordings of single live stream, in which 1 will do complete recording and 1 will create segment of live stream after every 30 seconds?

OR

To copy the stream from buffer?

OR

Any other way to accomplish this?

Thanks & Regards,

Touqeer

there used to be an API to get a single file from DVR or recored segments… try that?

option2 would work

or turn on DVR.

@Touqeer_Ahmad How you solved this ?

If you record the entire thing you can always use ffmpeg to cut out last 30 seconds.