title: Overwriting TS Stream File with FFMPEG in Linux
body: <p>I'm trying to convert rtmp streams to m3u8 stream. To reach that aim I use FFMPEG. Now, there is no problem with converting and downloading. However, it writes lots of .ts file such as channel0000.ts,channel0001.ts,channel0002.ts. Per every 10 seconds, 1 ts file is created. In this point, I want a single ts file. In other words, I need overwriting because I don't want to store all the stream I need just last 10 seconds. When I try to write on the same file I get this error:</p>
  
  <pre><code>Invalid segment filename template 'channel.ts'
  Could not write header for output file #0 (incorrect codec parameters ?):   Invalid argumentStream mapping:
  Stream #0:0 -&gt; #0:0 (copy)
  Stream #0:1 -&gt; #0:1 (copy)
  Last message repeated 1 times
  </code></pre>
  
  <p>Here is my FFMPEG command.</p>
  
  <pre><code>ffmpeg -loglevel quiet -i rtmp://example -c:v libx264 -profile:v baseline -level 3.1 -c:a aac -strict experimental -f mpegts - | ffmpeg -i - -c copy -map 0 -f segment -segment_list channel.m3u8 -segment_format mpegts -segment_time 10 channel%04d.ts
  </code></pre>
  
  <p>Any suggestion?</p>