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:

  1. 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?

  2. 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?

  • What did you settle on?
    – SeaDude
    Jun 10 at 7:00
  • 1
    Still working on it. Based on the experience thus far, I would go for recording in 1-minute chunks. Easier for replay, you can save on space with a better format and easier for cloud backup. @SeaDude
    – isaric
    Jun 11 at 8:06
  • What are you using for scripting the stream? Python?
    – SeaDude
    Jun 11 at 16:55
  • Bash is the scripting language that i am using @SeaDude
    – isaric
    Jun 12 at 8:53
  • 1
    github.com/isaric/recording-scripts @SeaDude this is basically it bu this approach is going for continuous one chunk recording in an appendable format
    – isaric
    Jun 12 at 8:54


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.