Hls.js: Local/offline playback + download support

Created on 5 Jun 2017  路  13Comments  路  Source: video-dev/hls.js

Hi I was wondering if there was the possibility of local playback / download support like ShakaPlayer?

The functionality is quite complex. It first parses the manifests and stores the data into an indexDB then rebuilds the manifest and data from this database for local playback.

Enhancement Feature proposal Help wanted Stale

Most helpful comment

@jimmywarting Downloading the manifest to an in-browser DB is quite complicated. However, it wouldn't be too much work (I think) to implement the file:// protocol, which enables local playback. Let's open this up and see if anyone wants to implement it.

All 13 comments

@jimmywarting Downloading the manifest to an in-browser DB is quite complicated. However, it wouldn't be too much work (I think) to implement the file:// protocol, which enables local playback. Let's open this up and see if anyone wants to implement it.

I'm not sure this should be implemented in the hls library as it's not something everyone would use, but probably in players sitting on top of it. We did something similar to this for site-to-multisite broadcasts. Our player is pretty much Chrome only and about 2000 lines of JS. We use the file system api, along with localstorage. Manifest entries are kept in a Map and occasionally flushed to disk as JSON. For hls.js integration, we configure with a custom fragment loader and playlist loader.

agree this should be made through custom loader.

Hm, then I got some question.

  • how would you build a custom fragment loader?
  • how do you build a custom playlist loader?
  • how can you download the hole movie in full speed in advance without buffering/watching the video?
  • how do you choose only one quality to download?
  • are there curtains constraints if you use DRM that makes you not able to play it offline?
  • what to do if it's a Live stream?

1, #2 https://github.com/video-dev/hls.js/blob/master/doc/API.md#loader

3 We use a chain of promises to download in sequence once a start point has been selected

4 That would be within your logic on how you handle the playlists...

5 I'm not sure

6 We do all this on live streams that have long playlist lengths on the server. Since both the fragment and segment loaders are custom, you can play back segments that no longer exist on the server or even restart the player without internet connectivity.... but as johnBartos mentioned, implementing something like this gets pretty complicated.

@eutychus would you care to share your code, is it open source?

Sorry, the code belongs to the company I work for and is heavily tied to the backend it connects to, so it probably wouldn't be easily adapted anyway... I was just trying to give you enough pointers to get an idea of what can be done and where to start if you wanted to build something like this out... (without having to touch the hls.js code). There is a lot of power in the ability to use custom loaders.

For reference Shaka player design notes on the subject can be found here.

+1 here! I want to save live videos and watch them when offline but all videos downloaded without sound. Please consider adding such a great option to this library.

any progress on this?

I'm attempting to do a custom loader (using something like abstract-chunk-store) but i still think it needs more core functionality... like getting a list of all fragments that you should download. and download/adding fragments without involving xhr or watching the movie.

Building a custom loader isn't good enough IMO. Needs something better built in...

Think a store option should be added... following something along what webtorrent are doing with abstrackt chunk store. Abr and levelcontroller should be aware of what exist and what not and load levels that exist.

Then we need some utilities function for downloading a level (quality) without having to watch the hole movie for example player.levelController.download(index) or hlsPlayer.levelController.levels[0].details.fragments[0].download()

And then some function for cleaning up stuff

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@eutychus could you give a more general explanation of how your team implemented that functionality? I tried use shaka player as well, but ir force the use of DRM in order to encrypt the HLS. (if it support to HLS with AES i didn't find any resource about it). Any help will be grateful.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NicholasAsimov picture NicholasAsimov  路  3Comments

GeorgySerga picture GeorgySerga  路  3Comments

itsjamie picture itsjamie  路  3Comments

eteubert picture eteubert  路  3Comments

shalommeoded picture shalommeoded  路  3Comments