How to save a stream to a file that would constantly change over time to have the right duration?
Computers don't let you delete from the start of a file, so every time you trim video away, would required the file to be completely re written. Not a great idea. It would be better use some a fragmented format like HLS or DASH, and delete old fragments.