Repository: youtube-dl
Issue: [downloader/hlsnative] Resuming encrypted HLS streams leads to broken files
Labels: bug

- [x] I've **verified** and **I assure** that I'm running youtube-dl **2016.10.21.1**
### Before submitting an _issue_ make sure you have:
- [x] At least skimmed through [README](https://github.com/rg3/youtube-dl/blob/master/README.md) and **most notably** [FAQ](https://github.com/rg3/youtube-dl#faq) and [BUGS](https://github.com/rg3/youtube-dl#bugs) sections
- [x] [Searched](https://github.com/rg3/youtube-dl/search?type=Issues) the bugtracker for similar issues including closed ones
### What is the purpose of your _issue_?
- [x] Bug report (encountered problems with youtube-dl)
- [ ] Site support request (request for adding support for a new site)
- [ ] Feature request (request for a new functionality)
- [ ] Question
- [ ] Other

```
[$] youtube-dl --hls-prefer-native http://www.hotstar.com/tv/savdhaan-india/363/the-promiscuous-wives/1000153444                 
[HotStar] 1000153444: Downloading JSON metadata
[HotStar] 1000153444: Downloading TABLET JSON metadata
[HotStar] 1000153444: Downloading m3u8 information
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 416
[download] Destination: The Promiscuous Wives-1000153444.mp4
```

Now twice the video has been downloaded but each time I have not been able to view the video either under mpv or vlc but when it is in .part I can play the video. It is only when it is complete, it doesn't play. I suspect some sort of corruption happening. 

This is the ouput I get while viewing the .part file via ffprobe -

```
[$] ffprobe The\ Promiscuous\ Wives-1000153444.mp4.part                                                                    
ffprobe version 3.1.4-1 Copyright (c) 2007-2016 the FFmpeg developers
  built with gcc 6.2.0 (Debian 6.2.0-6) 20161010
  configuration: --prefix=/usr --extra-version=1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-libtesseract --disable-stripping --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-frei0r --enable-chromaprint --enable-libopencv --enable-libx264
  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
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
[h264 @ 0x1693e00] non-existing SPS 0 referenced in buffering period
[h264 @ 0x1693e00] SPS unavailable in decode_picture_timing
[h264 @ 0x1693e00] non-existing SPS 0 referenced in buffering period
[h264 @ 0x1693e00] SPS unavailable in decode_picture_timing
[mpegts @ 0x168f3e0] PES packet size mismatch
Input #0, mpegts, from 'The Promiscuous Wives-1000153444.mp4.part':
  Duration: 00:11:12.00, start: 0.100667, bitrate: 2144 kb/s
  Program 1 
    Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 60 kb/s
```

Look forward to know more.