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

feat!: Add support for OTF format streams #351

Merged
merged 1 commit into from
Mar 13, 2023

Conversation

absidue
Copy link
Collaborator

@absidue absidue commented Mar 12, 2023

Description

Some videos have formats that are a bit different than other ones, YouTube seems to refer to these as OTF. According to NewPipeExtractor (https://github.com/TeamNewPipe/NewPipeExtractor/blob/dev/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/DeliveryType.java#L23-L38) these can occur on videos with low view counts and live stream replays that have just been reencoded to normal videos. Instead of allowing you to request arbitrary chunks with the range query parameter, instead you use the sq query parameter to request sequences, the first sequence (&sq=0) contains the duration of the sequences, so we need to request it while building the DASH manifest.

This implementation was inspired by the NewPipeExtractor implementation, so big thanks to them :).

Here is a video with OTF streams: https://www.youtube.com/watch?v=DJ8GQUNUXGM
The 720p and 360p streams are normal, the other ones (144p, 240p and 480p) are OTF streams

⚠️ Breaking change ⚠️

The toDash functions are now asynchronous, they return a Promise<string> instead of a string, as we need to fetch the first sequence while building the manifest.

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellings

for release please:

BEGIN_COMMIT_OVERRIDE
feat!: Add support for OTF format streams

BREAKING CHANGE: The toDash functions are now asynchronous, they now return a Promise<string> instead of a string, as we need to fetch the first sequence of the OTF format streams while building the manifest.
END_COMMIT_OVERRIDE

@absidue
Copy link
Collaborator Author

absidue commented Mar 12, 2023

Okay so apparently videos with OTF streams have the dash url field populated, so we don't need to generate these manifests in YouTube.js.

@LuanRT
Copy link
Owner

LuanRT commented Mar 12, 2023

I just tested this and also the dash manifest YouTube returns and both work great. This could be useful for those who need to filter out unwanted formats.

@absidue
Copy link
Collaborator Author

absidue commented Mar 12, 2023

Yep, just remembered that FreeTube can't use YouTube's one because, videojs-http-streaming (the part of video.js that handles DASH) only supports MP4-DASH, it doesn't support WebM-DASH.

@LuanRT LuanRT merged commit 3e4d41b into LuanRT:main Mar 13, 2023
@absidue absidue deleted the support-otf-streams branch March 13, 2023 05:08
@absidue absidue mentioned this pull request Mar 22, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants