title: ffmpeg limit number of segment file
body: <p>I'm learning in generating hls stream </p>
  
  <p>Curently my ffmpeg command looks like</p>
  
  <pre><code>ffmpeg -analyzeduration 100000000 -probesize 1000000 \
  -i https://nasa-i.akamaihd.net/hls/live/253565/NASA-NTV1-Public/master_500.m3u8 \
  -c:v copy -g 90 -c:a aac \
  -strict -2 \
  -strftime 1  -use_localtime 1 -g 90 \
  -hls_time 20 \
  -hls_list_size 15 \
  -hls_wrap 16 \
  -hls_segment_filename mydir/%Y-%m-%d_%H-%M-%S.ts \
  -f hls $4/index.m3u8 \
  -hls_flags delete_segments \
  </code></pre>
  
  <p>I want to have only 15 ts files with 20 seconds each.</p>
  
  <p>Problems are:</p>
  
  <ol>
  <li><p>It still generates more than 15 files, never deletes older files. While the index.m3u8 file content keeps updating and only has 15 ts listed.</p></li>
  <li><p>when I restart the command, index.m3u8 starts with only 1 file rather than updating it's list.</p></li>
  </ol>