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 (m3u8) and MPEG DASH (mpd) support? #223

Open
lpuglia opened this issue Jul 8, 2023 · 14 comments
Open

HLS (m3u8) and MPEG DASH (mpd) support? #223

lpuglia opened this issue Jul 8, 2023 · 14 comments

Comments

@lpuglia
Copy link

lpuglia commented Jul 8, 2023

Hello, I'm very keen to implement a stremio addon but i have a question about supported video formats. In theory ExoPlayer supports both HLS (m3u8) and MPEG DASH (mpd) with DRM (e.g. widevine). I can easily write a scraper that returns a DASH stream and its widevine keys. I have been implementing a stremio-like app in the past. My question is: are these formats supported by Stremio?

I don't see from this page what formats are precisely supported but maybe i'm just looking in the wrong place.

Sorry if this is a stupid question, i'm just starting to learn about stremio capabilities!

@jaruba
Copy link
Member

jaruba commented Jul 9, 2023

HLS is supported in all Stremio clients, DASH is not widely supported, although some clients like the Android TV app may work.

DRM is definitely not supported in any of the clients though.

I would experiment with both DASH and DRM support, but we don't have many example streams for such experimentation.

I noticed ur Reddit post also, I will comment with a link to this answer.

@lpuglia
Copy link
Author

lpuglia commented Jul 9, 2023

I have a question (sorry if it is trivial but I haven't looked into the docs very deeply):

What do you mean by stremio clients? Do you mean the actual executable that is used to run the app?

My question was really focusing on Android/Android TV version of stremio (sorry If I didn't make that clear), if I understand correctly the player that is used by default in android is based on ExoPlayer from Google (which is compatible with DRM protected Dash streams)

Here you can find a lots of mpd for testing purposes https://ottverse.com/free-mpeg-dash-mpd-manifest-example-test-urls/

I also have examples with Widevine encryption if you are interested.

@jaruba
Copy link
Member

jaruba commented Jul 9, 2023

By clients I mean each individual app for each platform:

  • Android Mobile
  • Android TV
  • Desktop
  • Web App

Each of them use different video players. The Android Mobile and Android TV apps are not the same app (although they share the same app id), we hope to release a version where we merge both of them into one app one day, but this won't happen soon.

Android TV uses ExoPlayer by default, and VLC as a backup if Exo fails to play, but users can switch to VLC as the default from settings if they so wish.

The Android Mobile app uses only VLC. On desktop we use MPV, and in the web app we use HTML5 <video> (complemented with HLS.js for HLS support)

For DRM, even if the video players support them, the addon sdk and the clients do not support passing the DRM keys to the video players.

IMHO the best way to support DRM is by creating a local proxy that decrypts the streams, then sends the locally decrypted streams to the video player (instead of the original one) as this will add support for DRM across all clients. (except web app in the case when a streaming server is not connected)

@lpuglia
Copy link
Author

lpuglia commented Jul 9, 2023

Thanks for the explanation!

I have been looking around, it seems that the mentioned players support DASH with DRM:

Exoplayer does it natively and I have been using it in the past

MPV
mpv-player/mpv#8286

For the web version you can use dash.js
https://github.com/Dash-Industry-Forum/dash.js/

The only problem is VLC, but if the plan for the future is to move to ExpPlayer for normal android as well, I would say that the most neat solution would be to just add another field to the Stream object (https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/responses/stream.md), this field would just need to contain the decryption key. At this point the client just needs to pass the URL and Key to the relevant player.

I think mpd is a really important format, for example Kodi supports it and the addons use it all the time.

@jaruba
Copy link
Member

jaruba commented Jul 9, 2023

but if the plan for the future is to move to ExpPlayer for normal android as well

This is far from a reality, I make no promises regarding future features or plans.

I would say that the most neat solution would be to just add another field to the Stream object ...

Although I didn't look into DRM decryption too much, I would presume that it needs both a secret and a key, not just a key. I could be wrong though..

At this point the client just needs to pass the URL and Key to the relevant player.

But this is not trivial, it would need to be researched, implemented and tested for every single client, while a DRM stream proxy would need to be done once and it would "just work" everywhere. Not that a DRM proxy is easy to implement, it is just the better solution for support considering many clients, and possibly more clients in the future.

Although I don't know much about Kodi or ever looked into it much, I did check their Netflix / HBO Go / etc project, which I believe also uses a local proxy for DRM. (yet again, I could be wrong, I looked into it a few years back)

@lpuglia
Copy link
Author

lpuglia commented Jul 15, 2023

Is there a starting point if I wanted to make modification to stremio itself? I would like to try few things so I could learn more. If you could link a guide or give some instructions on how to build the app from source for desktop it would be great!

@AltFreq07
Copy link

I did add shakaplayer to my own implementation, its not cleaned up though as i use it for my own stuff and dont really care but plays Dash, HLS and DRM (depends on browsers available DRM decoders). Also works in the QT5 app but you will likely need to have chrome installed as QT5 looks in that directory for widevine.dll or if you rebuild stremio-shell it you can point it to a custom location

Stremio/stremio-video@dc00a46

@lpuglia
Copy link
Author

lpuglia commented Nov 7, 2023

@AltFreq07
can you also add preAuth token? solution suggested by chatgpt:

player.configure({
    drm: {
      servers: {
        'com.widevine.alpha': 'YOUR_LICENSE_SERVER_URL'
      },
      advanced: {
        'com.widevine.alpha': {
          serverURL: 'YOUR_LICENSE_SERVER_URL',
          // Include the preauthorization token
          customData: {
            'Authorization': 'Bearer YOUR_PREAUTH_TOKEN'
          }
        }
      }
    }
  });

@AltFreq07
Copy link

@AltFreq07 can you also add preAuth token? solution suggested by chatgpt:

player.configure({
    drm: {
      servers: {
        'com.widevine.alpha': 'YOUR_LICENSE_SERVER_URL'
      },
      advanced: {
        'com.widevine.alpha': {
          serverURL: 'YOUR_LICENSE_SERVER_URL',
          // Include the preauthorization token
          customData: {
            'Authorization': 'Bearer YOUR_PREAUTH_TOKEN'
          }
        }
      }
    }
  });

I will implement something like this when i get to my next addon which will likely need this.

@mhdzumair
Copy link
Contributor

Any plans on adding mpd support?

@lpuglia
Copy link
Author

lpuglia commented Feb 24, 2024

@mhdzumair a current workaround is to use an external player such as mpv or just player

@mhdzumair
Copy link
Contributor

I'm expecting native stremio support :)

@jsolferreira
Copy link

Is it possible to use an external player like mpv to play a .mpd stream on AndroidTV? How would I create an addon that passes the stream and keys to the mpv player?

@mhdzumair
Copy link
Contributor

Implemented a solution to play MPEG DRM/non-DRM DASH stream in any player specially for stremio add-on https://github.com/mhdzumair/mediaflow-proxy, @jsolferreira you can implement the Stremio Addon to return the stream link of MPD stream with MediaFlow Proxy. Currently, this support Clear Key DRM and non DRM MPD with Live stream as well VOD static stream.

I will add similar MPD dash implementation support to stremio server if they okay with my implementation.

CC: @jaruba

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

No branches or pull requests

5 participants