xbmc / inputstream.adaptive

kodi inputstream addon for several manifest types
Other
454 stars 242 forks source link

HLS with Widevine support? (Disney+) #353

Closed matthuisman closed 4 years ago

matthuisman commented 4 years ago

@peak3d

Trying to playback some Disney+ streams and it appears they use HLS with widevine.

In the playlist:

#EXT-X-SESSION-KEY:METHOD=SAMPLE-AES-CTR,KEYFORMAT="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",KEYFORMATVERSIONS="1",URI="data:text/plain;base64,AAAAMnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABISEGlJ4uAaTEQRh7SKUAR6QAY="

SAMPLE-AES-CTR is apparently just CENC. The full playlist & substream list is attached.

Kodi seems to download the segments but never plays. I never see it even try to obtain the license from the license server Get "Unsupported encryption method: " So maybe first thing is to not error on EXT-X-KEY:METHOD=SAMPLE-AES-CTR. then maybe I could at least manually first download the playlist, get the pssh data and send that as license_data.

master_playlist.txt substream_playlist.txt

Another thing may be looking into also supporting EXT-X-SESSION-KEY (in master playlist) in case the substream doesn't contain EXT-X-KEY However, it appears Disney has both so not an issue here

matthuisman commented 4 years ago

This may help https://github.com/google/shaka-player/blob/c0f4f9da7b7ad5e8149cf8910ec62ab1cc1e0647/lib/hls/hls_parser.js#L1848

and this https://www.academia.edu/36030972/Widevine_DRM_for_HLS (scroll down to read)

michaelarnauts commented 4 years ago

I've read that Disney+ requires Widevine L1: https://www.androidpolice.com/2019/10/22/disney-will-only-work-on-devices-that-support-the-strictest-widevine-l3-drm/?amp (the URL indicated L3, but the article says L1.)

The Kodi implementation is L3 afaik, so I guess Widevine will refuse to continue.

yoshimo commented 4 years ago

Is this a clone of https://github.com/peak3d/inputstream.adaptive/issues/96?

matthuisman commented 4 years ago

@yoshimo Sample aes is different. This is cenc widevine encryption

@michaelarnauts In Chrome, EME logger says: robustness: SW_SECURE_DECODE Which is EME Level 2 = Widevine Level 3 https://websites.fraunhofer.de/video-dev/enabling-hardware-drm-on-android-chrome-using-the-encrypted-media-extensions/ However, the quality only goes upto 1280x720

EME Log attached EMELogFile.txt

glennguy commented 4 years ago

@matthuisman https://github.com/peak3d/inputstream.adaptive/blob/master/src/parser/HLSTree.cpp#L429 I think even if you allowed it to continue on METHOD=SAMPLE-AES-CTR the required flags would still need to be set as in https://github.com/peak3d/inputstream.adaptive/blob/master/src/parser/DASHTree.cpp#L186

I can have a look this week if I get time (and no-one else comes up with the solution beforehand)

michaelarnauts commented 4 years ago

It seems Disney+ lowered their security, and now also allows Linux clients. Maybe you have more succes now?

Source: https://www.omgubuntu.co.uk/2019/12/disney-plus-linux-support-fixed

matthuisman commented 4 years ago

Its been like that since I opened this request (WV Level 3) But maybe the higher quality streams are now also Level 3.

Still using HLS with Widevine though, so still need this added to IA

peak3d commented 4 years ago

We had this "HLS widevine" topic some month ago, but unfortunately I was not able to figure out how the workflow is. There must be some communication with a license server, but there was no URL for this.

1.) currently widevine for -ts files is not supported, would be good if disney has mp4 2.) smeone has to figure out, what license server URL should be used.

matthuisman commented 4 years ago

@peak3d For Disney, the license server is: https://global.edge.bamgrid.com/widevine/v1/obtain-license

Wouldn't it be the same as MPD where we pass the license_server url anyway? I can't recall the license servers being in the MPD files?

Also, Disney is using MP4 Files (well, in the content I tested) image

Attaches is EME log

        videoCapabilities:  [
                contentType:  video/mp4; codecs="avc1.4d401f"
                robustness:  SW_SECURE_DECODE]]

EMELogFile.txt

peak3d commented 4 years ago

cool, can you also provide one sub- video-playlist pls?

matthuisman commented 4 years ago

In my initial post I posted Master playlist and sub playlist :)

peak3d commented 4 years ago

ok, thx

matthuisman commented 4 years ago

PSSH data in the SAMPLE-AES-CTR attribute. And sometimes a KEYID may also be present apparently. Is that the KID?

https://github.com/google/shaka-player/blob/c0f4f9da7b7ad5e8149cf8910ec62ab1cc1e0647/lib/hls/hls_parser.js#L1848

I assume we will play these like so

#KODIPROP:inputstreamaddon=inputstream.adaptive
#KODIPROP:inputstream.adaptive.manifest_type=hls
#KODIPROP:inputstream.adaptive.license_type=com.widevine.alpha
#KODIPROP:inputstream.adaptive.license_key=https://global.edge.bamgrid.com/widevine/v1/obtain-license
https://vod-l3c-oc-east-1.media.dssott.com/ps01/disney/60a600e8-1306-4118-b96b-b0b1f783871a/regular-ctr-sw-cf87ce2e-67c1-4929-8969-f926e8f820d8.m3u8
peak3d commented 4 years ago

yes, KID is fine to have, if not I'll have to extractfrom first segment

peak3d commented 4 years ago

As you already stated above, should be not much more than setting encryted_state, and create a pssh_set, then it could already work

glennguy commented 4 years ago

@matthuisman I'm making some progress - the decrypter loads, contacts the license server but getting a 401. I can see the license request is meant to be sent with an auth header: authorization: Bearer eyJra.... I signed up for a 7 day trial so if you have an addon that I can test could you email it to me?

matthuisman commented 4 years ago

@glennguy I've pm'd you a test add-on on slack

@peak3d Yell out if you want a copy of the test add-on as well :)

matthuisman commented 4 years ago

got playback! Had to convert to MPD but shows it's possible :) (Only did video Representation) screenshot009

27hectormanuel commented 4 years ago

I can provide assets for Icons and more... @matthuisman, is there a way to test the add-on? Another question, does it currently supports 1080p playback?

peak3d commented 4 years ago

@matthuisman let us try to get it work without hls -> mpd conversion

matthuisman commented 4 years ago

@27hectormanuel max was 720p. Anything over that needed Widevine Level 1.

@peak3d Yes, the HLS was "messy". Wasn't sure how to get timings correct so seeking etc was broken. Also, every substream would need to be pulled to create the mpd (slow)

27hectormanuel commented 4 years ago

@matthuisman As promised. Disney Plus official assets: https://drive.google.com/open?id=1vKzsh3ru965_-Gf0x-OYK1VF2pvr7czJ

Btw, why not create a dedicated repository for this test add-on. You have the most important task, playback.

So excited to have Disney+ support on the Kodi Media Center!

glennguy commented 4 years ago

@27hectormanuel Matt's Disney addon isn't the holdup at the moment, there are a few things that need to happen inside inpustream.adaptive to get proper playback without any converting of HLS to MPD in the python addon (which is likely to be unreliable/easily broken)

We need:

I'm currently working on the second item, I think I'm capable of working it out, we will see this week!

27hectormanuel commented 4 years ago

Apart from Disney+ it should be investigated if the same time we could commence test development on a add-on for Movies Anywhere: https://moviesanywhere.com/ They may very well, utilize the same playback programming; I believe they do.

glennguy commented 4 years ago

disney @matthuisman I'll send you a zip on slack for testing

@peak3d I'll make 2 pull requests once I'm done replacing some of my 'hacks' with more palletable code - one for #EXT-X-MAP #EXT-X-KEY (widevine) and one for #EXT-X-DISCONTINUITY (periods). This use-case will also require #361 - would it be easier or better for you if I base them off that branch/each other or just from master?

matthuisman commented 4 years ago

Awesome work! Can't wait until it's merged :D

27hectormanuel commented 4 years ago

I see you utilized my provided assets.

On Sat, Jan 4, 2020, 11:34 PM Matt Huisman notifications@github.com wrote:

Awesome work! Can't wait until it's merged :D

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/peak3d/inputstream.adaptive/issues/353?email_source=notifications&email_token=AFOLQT7KX3GMABNUIEISKHLQ4FPN7A5CNFSM4JP4IOC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIDJJFY#issuecomment-570856599, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFOLQT7BRU4JPHNVN6SHTZ3Q4FPN7ANCNFSM4JP4IOCQ .

matthuisman commented 4 years ago

No we didn't sorry. That logo was just from google

On Mon, 6 Jan 2020, 11:01 AM Hector, notifications@github.com wrote:

I see you utilized my provided assets.

On Sat, Jan 4, 2020, 11:34 PM Matt Huisman notifications@github.com wrote:

Awesome work! Can't wait until it's merged :D

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/peak3d/inputstream.adaptive/issues/353?email_source=notifications&email_token=AFOLQT7KX3GMABNUIEISKHLQ4FPN7A5CNFSM4JP4IOC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIDJJFY#issuecomment-570856599 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AFOLQT7BRU4JPHNVN6SHTZ3Q4FPN7ANCNFSM4JP4IOCQ

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/peak3d/inputstream.adaptive/issues/353?email_source=notifications&email_token=ABPQAKPIG5D64SU3LRXHEDDQ4JKDNA5CNFSM4JP4IOC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIEAT3I#issuecomment-570952173, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPQAKJ6SCNRYAW3TDBDH5DQ4JKDNANCNFSM4JP4IOCQ .

insert-usernamehere commented 4 years ago

Can I instal this right now

peak3d commented 4 years ago

Matrix branch has this fix merged, 2.5.4 is the version of inputstream.adaptive

matthuisman commented 4 years ago

@montgomery28 No - pretty sure two more PRs need to be merged (@glennguy) to allow for HLS Widevine playback. Once they are merged, you will need to then use Kodi Nightly (Matrix) builds. And I'll also need to finish the actual Disney add-on (not too much work). And quality is limited to 720p (but full resolution should be available on Kodi Android)

insert-usernamehere commented 4 years ago

Ok thanks

Testato commented 4 years ago

Thanks to all for this work. Will this help for Sample-Aes implementation ? https://github.com/peak3d/inputstream.adaptive/issues/96

glennguy commented 4 years ago

@Testato No. SAMPLE-AES in the m3u8 provided in #96 is Apple Fairplay - inputstream adaptive doesn't support it currently, and if it did it would only ever be in iOS/MacOS as far as I can tell.

Testato commented 4 years ago

@glennguy thanks for clarification. The tv channel is also streamed via .mpd, it is supported ? https://d15umi5iaezxgx.cloudfront.net/OUT/DASH/Live.mpd

matthuisman commented 4 years ago

Yes. Mpd is supported. That is called Dash. It most likely will have Widevine encryption as well

juni745 commented 4 years ago

@matthuisman how did you convert the hls to mpd dash?

skarragallagher commented 4 years ago

@montgomery28 No - pretty sure two more PRs need to be merged (@glennguy) to allow for HLS Widevine playback. Once they are merged, you will need to then use Kodi Nightly (Matrix) builds. And I'll also need to finish the actual Disney add-on (not too much work). And quality is limited to 720p (but full resolution should be available on Kodi Android)

Is there a forum thread on this that i can follow to track development. Highly interested in this

insert-usernamehere commented 4 years ago

Well codent you use a upscaling system for high res my TV only goes to 720p but I assume it would be possible. Edit I did some gogleing there is an upscaling feature included in Kodi so if you find the pointers to it you can upscale

glennguy commented 4 years ago

@skarragallagher There's this thread in the requests section: https://forum.kodi.tv/showthread.php?tid=342927

The holdup at the moment is getting #395 merged but we just have to be patient. I can only imagine most people (peak3d included) are extremely busy right now with what's going on in the world. Once that is done add-on development will likely be very quick.

matthuisman commented 4 years ago

ill need to check but I suspect we will be able to get full res on Kodi on Android.

skarragallagher commented 4 years ago

Looks like some activity on this may be happening :) Anything i can do to help beta test etc. let me know

matthuisman commented 4 years ago

required code was merged last night https://github.com/peak3d/inputstream.adaptive/commit/396350243e16557a3e3bf066c4c57204eb98972e and Slyguy almost has the Disney+ add-on ready: https://twitter.com/Slyguy_xyz/status/1247984960255877120

closing this issue as this has now been implemented!

matthuisman commented 4 years ago

The Disney+ Kodi Add-on (by SlyGuy) is now available: https://www.matthuisman.nz/2020/04/disney-plus-kodi-add-on.html

michaelarnauts commented 4 years ago

@matthuisman can this be tracked in a GitHub repository somewhere?

27hectormanuel commented 4 years ago

@matthuisman, Can you help me create a "Movies Anywhere" & "Hulu" add-on?

Also, is anyone looking for a possible way FHD playback could be achieved through WIN 10?

johannesschauer97 commented 4 years ago

Dear @matthuisman! Thank you for the great work til' now! I have some problems with the playback. On my RaspberryPi4 I am able to login to Disney+ but if I want to play something I only get "Unbekannter Fehler". The according part in the log: 2020-04-12 21:47:56.111 T:2308923600 ERROR: slyguy.disney.plus - Traceback (most recent call last): File "/home/pi/.kodi/addons/script.module.slyguy/resources/lib/slyguy/mem_cache.py", line 29, in load cache.data = cPickle.loads(data.encode('latin1')) EOFError 2020-04-12 21:48:02.084 T:2308923600 ERROR: slyguy.disney.plus - Unbekannter Fehler 2020-04-12 21:48:04.154 T:2972867680 NOTICE: VideoPlayer::OpenFile: plugin://slyguy.disney.plus/?_=play&_play=1&media_id=509062c4-e942-4d86-b7a4-d294ada71570&original_lang=en 2020-04-12 21:48:04.155 T:2972867680 ERROR: CCurlFile::Stat - Failed: URL using bad/illegal format or missing URL(3) for http://|connection-timeout=30 2020-04-12 21:48:04.171 T:2284499152 NOTICE: Creating InputStream 2020-04-12 21:48:04.172 T:2284499152 ERROR: CCurlFile::FillBuffer - Failed: URL using bad/illegal format or missing URL(3) 2020-04-12 21:48:04.172 T:2284499152 ERROR: CCurlFile::Open failed with code 0 for http://: 2020-04-12 21:48:04.173 T:2284499152 ERROR: CCurlFile::FillBuffer - Failed: URL using bad/illegal format or missing URL(3) 2020-04-12 21:48:04.173 T:2284499152 ERROR: CCurlFile::Open failed with code 0 for http://: 2020-04-12 21:48:04.173 T:2284499152 ERROR: Open - failed to open source <http://|connection-timeout=30> 2020-04-12 21:48:04.173 T:2284499152 ERROR: CVideoPlayer::OpenInputStream - error opening [plugin://slyguy.disney.plus/?_=play&_play=1&media_id=509062c4-e942-4d86-b7a4-d294ada71570&original_lang=en] 2020-04-12 21:48:04.173 T:2284499152 NOTICE: CVideoPlayer::OnExit() 2020-04-12 21:48:04.282 T:2972867680 NOTICE: CVideoPlayer::CloseFile() 2020-04-12 21:48:04.283 T:2972867680 NOTICE: VideoPlayer: waiting for threads to exit 2020-04-12 21:48:04.283 T:2972867680 NOTICE: VideoPlayer: finished waiting

I already tried to play with different versions of Widevine, but nothing changed.

matthuisman commented 4 years ago

@johannesschauer97 full debug log please

johannesschauer97 commented 4 years ago

@matthuisman kodi.log

matthuisman commented 4 years ago

Does it do it for all content? The http:// error is what the add-on does to stop auto playing the next item. The error comes before that.

What is the content your trying to play in that log? Name please so I can replicate