videojs / http-streaming

HLS, DASH, and future HTTP streaming protocols library for video.js
https://videojs-http-streaming.netlify.app/
Other
2.53k stars 425 forks source link

AES-128 encrypted fmp4 stream does not play #1331

Open phloxic opened 2 years ago

phloxic commented 2 years ago

Description

The problem can be reproduced in the netlify demo

The same stream plays fine in macOS Safari when overrideNative is turned off. – Disclaimer: Did not test on iOS. There was/is also a bug in some Safari versions (ca. 13.x, 14.x?), but it seems to be fixed.

Sources

As per description, only AES-128 encrypted fmp4.

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

  1. Try to play AES-128 encrypted fmp4 in vhs
  2. Observe it hanging/erroring out (see below)

Results

Expected

Stream should play like in native HLS.

Error output

This is the error in Chrome:

Uncaught RangeError: byte length of Int32Array should be a multiple of 4
    at new Int32Array (<anonymous>)
    at new Decrypter (f3444381-a506-4704-8708-e0c883ac544d:583:26)
    at self.onmessage (f3444381-a506-4704-8708-e0c883ac544d:714:6)

videojs-http-streaming version

videojs-http-streaming 2.15.0 -- did it ever work?

videojs version

video.js 7.21.0 -- did it ever work?

Browsers

All browsers I could get hold of on macOS 10.15.7

Platforms

macOS 10.15.7 and Android

Other Plugins

No other plugins.

Other JavaScript

None.

video-archivist-bot commented 2 years ago

Hey! We've detected some video files in a comment on this issue. If you'd like to permanently archive these videos and tie them to this project, a maintainer of the project can reply to this issue with the following commands:

phloxic commented 2 years ago

The problem can be narrowed down to AES-128 encrypted fmp4 (single file) with byte-range requests.

AES-128 encrypted fmp4 segmented into actual m4s files seem to work, but break easily on quick resolution changes (e.g. manually or by going fullscreen).

phloxic commented 2 years ago

The issue is caused by init segments whose byte-range is not divisible by 4, e.g.

#EXT-X-MAP:URI="108p.mp4",BYTERANGE="799@0"

However, this is allowed for init and iframe segments: https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-08#section-6.3.6 See also how this was solved in hls.js: https://github.com/video-dev/hls.js/pull/4941

nikhilnayyar2 commented 2 years ago

facing the same issue. Can this be fixed soon?