Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[downloader/hls] fix EXT-X-BYTERANGE off-by-one bug #24512

Merged

Conversation

basicmaster
Copy link
Contributor

Please follow the guide below

  • You will be asked some questions, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])
  • Use Preview tab to see how your pull request will actually look like

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

The end of the byte range is the first byte that is NOT part of the to
be downloaded range. So don't include it into the requested HTTP
download range, as this additional byte leads to a broken TS packet and
subsequently to e.g. visible video corruption.

Fixes #14748.

The end of the byte range is the first byte that is NOT part of the to
be downloaded range. So don't include it into the requested HTTP
download range, as this additional byte leads to a broken TS packet and
subsequently to e.g. visible video corruption.

Fixes #14748.
@basicmaster
Copy link
Contributor Author

Note that the subtraction of 1 is only applied to the download itself (instead of directly to the byte_range array), as byte_range['end'] may be reused from a previous media segment, in a simpler form of an HLS playlist.

E.g. Reddit seems to use the byte range just to provide fast random access - all the media segments just cover the entire ES completely one-after-another. So you can verify the correct result by just downloading the video ES of a Reddit video before/after the fix and compare it with the plain file the applicable playlist refers to:

youtube-dl -f hls-871 https://www.reddit.com/r/BitchImATrain/comments/fg99jb/bitch_im_a_cow/

vs.

https://v.redd.it/tblt9361csl41/HLS_270.ts

@basicmaster
Copy link
Contributor Author

I was wondering whether there is something new here, as this is a site-independent problem and possibly affects other sites than only Reddit...

@dstftw dstftw merged commit 6e65a2a into ytdl-org:master Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prefer ffmpeg HLS decoder for v.redd.it
2 participants