videogular / ngx-videogular

The HTML5 video player for Angular 2 and successor to videogular2
MIT License
131 stars 35 forks source link

Support ClearKey Encrypted HLS #34

Open tiberiumihai opened 4 years ago

tiberiumihai commented 4 years ago

Description

I've packaged encrypted media files into dash and hls using MP4Box using filters to generate both manifests (dash and hls) manifest.m3u8:dual. Dual filter was introduced in GPAC v0.9.0. More info about this here: https://github.com/gpac/testsuite/blob/filters/scripts/hls-gen.sh

vgDash is working great with ClearKey DRM but I'm stuck with Hls on Safari.

I'm using both dash and hls directives:

<video ... [vgDash]="video.dashManifest"
               [vgHls]="video.hlsManifest"
               [vgDRMToken]="video.token"
               [vgDRMLicenseServer]="video.licenseServers"><track ... /></video>

And I'm changing bitrates based on this value:

  get isHlsSupported() {
    const videoElement = this.videoPlayer?.nativeElement;
    const hlsSupported = videoElement && videoElement.canPlayType("application/vnd.apple.mpegurl");
    if (hlsSupported) {
      console.log("HLS SUPPORTED BROWSER");
    }
    return hlsSupported;
  }

I see that vgDRMToken and vgDRMLicenseServer are available only for vgDash. Is there any other way to specify ClearKey for vgHls?

I've seen this comment (https://github.com/video-dev/hls.js/issues/2901#issuecomment-661275833) and I think ClearKey support will be introduced in hls.js@v1.0.0.

Expected Behavior

ClearKey Encrypted Hls to work.

Actual Behavior

Currently, the player, loads manifest.m3u8 playlist and associated segments, but can not decrypt and displays 00:00 video.

Steps to Reproduce

  1. Encrypt video and audio files
  2. Generate dash and hls manifest.m3u8:dual based on encrypted media
  3. Use [vgHls]="'http://localhost:/manifest.m3u8'"
  4. hls can not decrypt video stream. No errors in console though.

Attachments

HLS Supported in Safari

DASH Supported in Chrome

tiberiumihai commented 4 years ago

ClearKey support will be added into hls.js@v1.0.0 PR here: https://github.com/video-dev/hls.js/pull/2934

Maybe we can add support for hls as well. I can help with this once the PR is merged and released in hls.js.

IxquitilisSaid commented 4 years ago

Yeah for sure! I subscribed to the HLS PR so we can fix it as soon as it's merged šŸ‘€

IxquitilisSaid commented 3 years ago

Pinging to prevent stale status They sure do be taking their time to merge it...

tiberiumihai commented 3 years ago

Yes...

Update: For my project I've ditched clear key support in favour of AES-128, and dash in favour of fragmented hls. Safari doesn't support ClearKey anyway, and most major browsers would work with AES-128 fragmented hls, including Safari. So, even if hls.js player is adding support for ClearKey, a ClearKey encrypted stream won't work in Safari (Web, iPhone or iPads).

IxquitilisSaid commented 3 years ago

Thanks, Apple. Very cool... šŸ™„ Anyway... I glad you found a workaround for your project šŸ˜„ , as for the PR once it's merged I'll add support for it either way. Hopefully, no one will try it on Safari

tiberiumihai commented 3 years ago

If you need help, I can help as well, let me know. Thanks!

IxquitilisSaid commented 3 years ago

Aye! I'll ping you if something comes up Thanks, once again! šŸ˜„

naktinis commented 3 years ago

Just mentioning this in case anyone else looks for this in the future. If I read it right, there's a recent WebKit ticket to move this forward on Safari ā€“ https://bugs.webkit.org/show_bug.cgi?id=231006.