title: How to save (record) rtsp stream to the disk storage without artifacts and missing seconds?
body: <p>I need to save (record) rtsp stream to the disk storage.
  I am using nginx-module and ffmpeg for it.
  Here the config for enable recording:</p>
  
  <pre><code>rtmp {
      live on;
      hls on;
      hls_fragment 5s;
      server {
          listen 1935;
          application cam1 {
              hls_path /tmp/cam1;
          }
          exec_static ffmpeg -rtsp_transport tcp -i rtsp://... -c copy -f flv rtmp://.../cam1/stream;
      }
  }
  </code></pre>
  
  <p>Config is creating the flv files, each duration of 5 second.
  Then we need to merge all got files in one file by command: </p>
  
  <pre><code>ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.flv
  </code></pre>
  
  <p>After concated files we are got a problem. When previous 5 seconds end and start next 5 seconds we have artifacts and missing 0.5-1 second.</p>
  
  <p>Please, get me help with saving rtsp stream without artifacts and missing seconds.</p>