ffmpeg incorrect duration when converting video to HLS
<p>I'm facing an issue using ffmpeg to convert video, precisely mp4 video => Http Live Streaming (HLS) </p>

<p>Once converted to HLS, the .m3u8 file has a wrong duration (e.g : 20,1s  instead of 20.00s), causing bugs when playing it with AVPlayer on iOS.
Playing the video with Safari cause the same issue.</p>

<p><strong>Example :</strong><br>
1) Open Safari<br>
2) <a href="http://www.appscenes.fr/294/playlist.m3u8" rel="nofollow">Play this video that i've converted</a><br>
3) Look at the download progression, stopped at 98% cause of wrong duration.<br>
<a href="https://i.stack.imgur.com/MLQJ5.png" rel="nofollow"><img src="https://i.stack.imgur.com/MLQJ5.png" alt="enter image description here"></a><br>
4) When you slide between 98% and 100%, the video player can crash.</p>

<hr>

<p><strong>EDIT 1 :</strong></p>

<p>I've edited the command line</p>

<pre><code> ffmpeg -i  video.mp4 \
 -codec copy \
 -acodec copy \
 -map 0 -f ssegment -g 60 -sc_threshold 0 \
 -segment_list playlist.m3u8 \
 -segment_list_flags +live \
 -segment_time 2 media%05d.ts \
  &gt;./log_ffmpeg 2&gt;./log_ffmpeg
</code></pre>

<p>LOG :</p>

<pre><code>ffmpeg version 3.1.4-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.1 (Debian 5.4.1-2) 20160904
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --enable-frei0r --enable-libfribidi --disable-indev=sndio --disable-outdev=sndio --enable-librtmp --enable-libzimg --cc=gcc-5 --disable-ffplay
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './Comptes/1/Photos/306/original_video.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp41mp42isom
    creation_time   : 2016-10-12 14:29:51
  Duration: 00:00:20.00, start: 0.000000, bitrate: 1673 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 540x960, 1563 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      creation_time   : 2016-10-12 14:29:51
      handler_name    : Core Media Video
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 101 kb/s (default)
    Metadata:
      creation_time   : 2016-10-12 14:29:51
      handler_name    : Core Media Audio
[stream_segment,ssegment @ 0x652ed80] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
    Last message repeated 1 times

Output #0, stream_segment,ssegment, to './Comptes/1/Photos/306/media%05d.ts':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp41mp42isom
    encoder         : Lavf57.41.100
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 540x960, q=2-31, 1563 kb/s, 30 fps, 30 tbr, 90k tbn, 600 tbc (default)
    Metadata:
      creation_time   : 2016-10-12 14:29:51
      handler_name    : Core Media Video
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, 101 kb/s (default)
    Metadata:
      creation_time   : 2016-10-12 14:29:51
      handler_name    : Core Media Audio
Stream mapping:
  Stream #0:0 -&gt; #0:0 (copy)
  Stream #0:1 -&gt; #0:1 (copy)
Press [q] to stop, [?] for help
frame=  601 fps=0.0 q=-1.0 Lsize=N/A time=00:00:20.10 bitrate=N/A speed= 917x    
video:3823kB audio:249kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
</code></pre>

<p>m3u8 file :</p>

<pre><code>#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:3
#EXTINF:2.033333,
media00000.ts
#EXTINF:2.000000,
media00001.ts
#EXTINF:2.000000,
media00002.ts
#EXTINF:2.000000,
media00003.ts
#EXTINF:2.000000,
media00004.ts
#EXTINF:2.000000,
media00005.ts
#EXTINF:2.000000,
media00006.ts
#EXTINF:2.000000,
media00007.ts
#EXTINF:2.000000,
media00008.ts
#EXTINF:2.000000,
media00009.ts
#EXTINF:0.033333,
media00010.ts
#EXT-X-ENDLIST
</code></pre>

<p><strong>As you can see input duration =/= output duration</strong><br>
input duration : 20s<br>
output duration 20.1s</p>