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

HLS Support #346

Closed
4 tasks done
ronnie-codes opened this issue Mar 10, 2023 · 11 comments
Closed
4 tasks done

HLS Support #346

ronnie-codes opened this issue Mar 10, 2023 · 11 comments
Labels
question Further information is requested

Comments

@ronnie-codes
Copy link
Contributor

Question

I hope we can remain civilized here. My question is: How do I make hlsManifestUrl not null? Does this project support HLS or just DASH?

Other details

No response

Checklist

  • I am running the latest version.
  • I checked the documentation and found no answer.
  • I have searched the existing issues and made sure this is not a duplicate.
  • I have provided sufficient information.
@ronnie-codes ronnie-codes added the question Further information is requested label Mar 10, 2023
@absidue
Copy link
Collaborator

absidue commented Mar 10, 2023

The hlsManifestUrl and dashManifestUrl fields are provided by YouTube, usually they only seem to provide them for currently live live streams and currently live premiere videos. Those manifests are served from YouTube's own servers.

This library has a function, VideoInfo#toDash, that generates a DASH manifest for non-live/normal videos, from the array of adaptive formats that YouTube returns in their API response. The function returns the manifest XML as a string which you can then pass to a player or write to the filesystem or something.

I haven't looked into HLS very much but as I understand it, it's made up of many smaller manifests. It might be possible to generate HLS manifests, the same way that this library is capable of generating DASH manifests, however as that array of adaptive formats is intended to be used with DASH (YouTube uses DASH in their own player, but they pass all the data to their player directly, instead of going through an XML manifest), I don't know how well they would work with HLS.

@ChunkyProgrammer
Copy link
Contributor

I think using an IOS client might make the HLS Url more frequent

@ronnie-codes
Copy link
Contributor Author

ronnie-codes commented Mar 13, 2023

You are correct that the hls_manifest_url is provided for live streams.

After taking a look at the adaptive formats, it is possible but not feasible to create an HLS manifest from what is given. The way HLS works, the "manifest" is an index of indices, and each child index contains a list of URLs to 10-second video segments. I would have to automate downloading each file for each resolution and then process each into segments and host all of that myself and then generate indices which I would also need to host myself. Alternative solution: I am going to use a 3rd party player which supports DASH, where Apple's out of the box player does not.

Thank you both for your valuable time.

@LuanRT
Copy link
Owner

LuanRT commented Mar 13, 2023

@ChunkyProgrammer is correct.

@ronnie-codes
Feel free to open a feature request issue regarding the iOS InnerTube client if you think that would help your use case.

@ronnie-codes
Copy link
Contributor Author

@LuanRT, I was able to leverage f4e0f30 as my true north, and I now have proper iOS client support in place. I'll make a pull request to your repo sometime soon.

@Duell10111
Copy link
Contributor

For everyone needing a code sample how to generate a hls playlist using this library, here a test repo:
https://github.com/Duell10111/yt.js-hls-proto/tree/segmentation-support

@ronnie-codes
Copy link
Contributor Author

For everyone needing a code sample how to generate a hls playlist using this library, here a test repo: https://github.com/Duell10111/yt.js-hls-proto/tree/segmentation-support

I forked this repo and added HLS support by simply adding an iOS client parameter a while ago. I can open a PR if anybody cares.

@Duell10111
Copy link
Contributor

@ronnie-codes Does that work for any video, not only live streams?

A PR would be great for me. :)

@LuanRT
Copy link
Owner

LuanRT commented Aug 7, 2023

@Duell10111 Great work on that! If this helps, using an iOS user agent or Safari context data will make InnerTube return the hls manifest (and sometimes, a hlsFormats array in the streaming data object). Not sure how reliable it is though.

@ronnie-codes
Copy link
Contributor Author

I'll open a PR later tonight if luan wants it.

@ronnie-codes
Copy link
Contributor Author

See #467.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants