Repository: ytdl-org/youtube-dl

Issue:
Prefer ffmpeg HLS decoder for v.redd.it
### Make sure you are using the *latest* version: run `youtube-dl --version` and ensure your version is *2017.11.15*. If it's not, read [this FAQ entry](https://github.com/rg3/youtube-dl/blob/master/README.md#how-do-i-update-youtube-dl) and update. Issues with outdated version will be rejected.
- [x] I've **verified** and **I assure** that I'm running youtube-dl **2017.11.15**

### Before submitting an *issue* make sure you have:
- [x] At least skimmed through the [README](https://github.com/rg3/youtube-dl/blob/master/README.md), **most notably** the [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

---

### Description of your *issue*, suggested solution and other information

Site v.reddit.com should prefer ffmpeg HLS downloader instead of native. Using the native downloader results in some video corruption and artifacting, e.g. visible within the first few seconds of this source: `youtube-dl https://v.redd.it/poqkxthgcpxz`


Discussion:
Just a note for anyone wonder how to use the **ffmpeg HLS downloader**, add the `--hls-prefer-ffmpeg` flag to your command.

So using OP's sample URL, to get rid of the video corruption / artifacts, you'd run

    youtube-dl --hls-prefer-ffmpeg https://v.redd.it/poqkxthgcpxz
--hls-prefer-ffmpeg give a worse result in [my case](https://github.com/ytdl-org/youtube-dl/issues/22542), which I had glitches.
youtube-dl --hls-prefer-ffmpeg https://v.redd.it/5k899ezasdp31
The result is a completely broken video. The only way to download this video, without glitches, is through ripsave.com
For me, the native downloader yields playable results (generally and for the example linked by @alext69), while videos downloaded with the ffmpeg downloader have video glitches, desynced audio and usually only play video for a few seconds after which only audio can be heard. Specifically, I can get the downloaded video to play in mpv but not the URL directly.

```
$ mpv https://v.redd.it/5k899ezasdp31 --ytdl-raw-options=hls-prefer-native=     
```

youtube-dl 2020.01.15
mpv 0.30.0
@alext69 @FichteFoll I can also confirm that `--hls-prefer-ffmpeg` causes the audio desync/audio-only after X seconds issue.

Seems you have to choose between video artifacts every 6 seconds or broken video + desynced audio.

Resolving patch:
diff --git a/youtube_dl/downloader/hls.py b/youtube_dl/downloader/hls.py
--- a/youtube_dl/downloader/hls.py
+++ b/youtube_dl/downloader/hls.py
@@ -141,7 +141,7 @@ def is_ad_fragment_end(s):
                     count = 0
                     headers = info_dict.get('http_headers', {})
                     if byte_range:
-                        headers['Range'] = 'bytes=%d-%d' % (byte_range['start'], byte_range['end'])
+                        headers['Range'] = 'bytes=%d-%d' % (byte_range['start'], byte_range['end'] - 1)
                     while count <= fragment_retries:
                         try:
                             success, frag_content = self._download_fragment(


Test patch: