I am recording an IP camera stream using ffmpeg.
Here are the goals that I want to achieve:
Record an entire day in a single file
In case of a disconnect be able to restart the process and continue recording to the same file (appending to the previous content, not overwriting)
Be able to view the recorded content as its being recorded (so the format and codec should not need finalization)
I've tried a few approaches. In the end I settled on recording in the TS format because it allows for easy appending. The issue is that those files end up being huge (cca 20-25 GB per day). I can have a follow up job that compresses them but I don't see any way to do this that isnt either CPU intensive or takes 5 times as long as the video duration to complete.
If I record using any other format like .mkv or .mp4 then appending to the file causes errors. Either not all of the content can be viewed or at the very least time seeking is broken.
I've also tried recording in smaller chunks and then appending them. That also works, producing files that are without errors and with a decent size. If all else fails I will return to this approach. I would like to avoid this if possible, though.
This breaks down into two questions:
If I stick to recording using the TS format: Is there any non-resource-intensive way to bring the file size down under 10 GB after the file has finished recording?
If I change the file format (and codec) to something that is more manageable from the start: Can I somehow append to the existing file without breaking it? Or can I fix those errors in a second run?