Body: <p>I am recording an IP camera stream using ffmpeg.</p>
  <p>Here are the goals that I want to achieve:</p>
  <ul>
  <li><p>Record an entire day in a single file</p>
  </li>
  <li><p>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)</p>
  </li>
  <li><p>Be able to view the recorded content as its being recorded (so the format and codec should not need finalization)</p>
  </li>
  </ul>
  <p>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.</p>
  <p>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.</p>
  <p>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.</p>
  <p>This breaks down into two questions:</p>
  <ol>
  <li><p>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?</p>
  </li>
  <li><p>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?</p>
  </li>
  </ol>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-06-10T07:00:25.197Z
Comments.Text: What did you settle on?
Comments.UserDisplayName: SeaDude
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-06-11T08:06:47.987Z
Comments.Text: 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
Comments.UserDisplayName: isaric
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-06-11T16:55:14.377Z
Comments.Text: What are you using for scripting the stream? Python?
Comments.UserDisplayName: SeaDude
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-06-12T08:53:22.540Z
Comments.Text: Bash is the scripting language that i am using @SeaDude
Comments.UserDisplayName: isaric
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-06-12T08:54:28.147Z
Comments.Text: https://github.com/isaric/recording-scripts @SeaDude this is basically it bu this approach is going for continuous one chunk recording in an appendable format
Comments.UserDisplayName: isaric
Tags: <ffmpeg>
Title: Recording IP camera RTSP Stream with FFMPEG - append to file
UserDisplayName: isaric
ThreadText: # Recording IP camera RTSP Stream with FFMPEG - append to file
  
  (Asked by: username_0 on 2022-01-03)
  
  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?
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: What did you settle on?  
  > **username_0**: 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. @username_1  
  > **username_1**: What are you using for scripting the stream? Python?  
  > **username_0**: Bash is the scripting language that i am using @username_1  
  > **username_0**: https://github.com/username_0/recording-scripts @username_1 this is basically it bu this approach is going for continuous one chunk recording in an appendable format  
  
  ---
  
  ## 0 answers
  
  