title: Save continuous RTSP stream to 5-10 minute long mp4 files
body: <p>How can I keep the flow (protocol rtsp, codec h264) in file (container mp4)? That is, on inputting an endless stream (with CCTV camera), and the output files in mp4 format size of 5-10 minutes of recording time.</p>
  
  <p>OS: debian, ubuntu
  Software: vlc, ffmpeg (avconv)</p>
  
  <p>Currently this scheme is used:</p>
  
  <pre><code>cvlc rtsp://admin:admin@10.1.1.1:554/ch1-s1 --sout=file/ts:stream.ts
  ffmpeg -i stream.ts -vcodec copy -f mp4 stream.mp4
  </code></pre>
  
  <p>But it can not record video continuously (between restarts vlc loses about 10 seconds of live video).</p>