title: ffmpeg hls duation is wrong on m3u8
body: <p>I am using ffmpeg to store the video in hls format using below command</p>
  <pre><code>~/bin/ffmpeg -r 15 -i rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov -codec copy -hls_list_size 65535 -hls_time 2 -g 2 &quot;./live.m3u8&quot;
  </code></pre>
  <p>where I am getting lists of ts file and live.m3u8 file. Note in above command the duration of hls file segment set 2 second.</p>
  <p>Here is the content of live.m3u8</p>
  <pre><code>#EXTM3U
  #EXT-X-VERSION:3
  #EXT-X-TARGETDURATION:2
  #EXT-X-MEDIA-SEQUENCE:0
  #EXTINF:2,
  live0.ts
  #EXTINF:2,
  live1.ts
  #EXTINF:2,
  live2.ts
  #EXTINF:2,
  live3.ts
  #EXTINF:1,
  live4.ts
  #EXTINF:2,
  live5.ts
  #EXT-X-ENDLIST
  </code></pre>
  <p>Note in above file the duration is not always 2 second and it varies. And When I check the duration of actual ts file segment using ffprob I am getting float value,</p>
  <p>For example,</p>
  <pre><code>~/bin/ffprobe -i live3.ts -show_entries format=duration -v quiet -of csv=&quot;p=0&quot;
  </code></pre>
  <p>gives <code>2.261556</code></p>
  <p>And</p>
  <pre><code>~/bin/ffprobe -i live4.ts -show_entries format=duration -v quiet -of csv=&quot;p=0&quot;
  </code></pre>
  <p>gives the duration <code>1.298256</code></p>
  <p>It seems the ffmpeg file round the <code>float</code> value to <code>int</code> and write to live.m3u8 file. This cause some problem in seeking the video file(seek to incorrect timestamp) and also the total duration of video file is always displayed less than the actual duration. For example, if I record the video for 2 hour, and open the live.m3u8 using vlc player, I can see that the video duration is displayed 1:45 min and I am able to seek up to 2 hours.</p>
  <p>What could be the issue,</p>
  <p><strong>ffmpeg version:</strong> <code>ffmpeg version git-2014-06-24-b52637c</code></p>
  <p><strong>Reference image</strong></p>
  <p><a href="https://i.stack.imgur.com/Gqe11.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gqe11.jpg" alt="enter image description here" /></a></p>
  <p><strong>Edit:</strong></p>
  <p>I have updated the ffmpeg to newer version based on the instruction here <a href="https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu" rel="nofollow noreferrer">https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu</a>. But still some issue. Now the  live.m3u8 files generates the timing information in float, but the value is not accurate.
  For example</p>
  <p>The m3u8 file generated is</p>
  <pre><code>#EXTM3U
  #EXT-X-VERSION:3
  #EXT-X-TARGETDURATION:3
  #EXT-X-MEDIA-SEQUENCE:0
  #EXTINF:3.200000,
  live0.ts
  #EXTINF:3.100000,
  live1.ts
  #EXTINF:3.100000,
  live2.ts
  #EXTINF:2.340000,
  live3.ts
  #EXT-X-ENDLIST
  </code></pre>
  <p>and if I check the duration of <code>live0.ts</code> using the command <code>~/bin/ffprobe -i live0.ts -show_entries format=duration -v quiet -of csv=&quot;p=0&quot;</code> it print <code>2.3333</code> where as in the playlist file it's <code>3.200000</code>.</p>
  <p>What could be the issue?.</p>