fix(drm): add zero-KID fallback for mp4decrypt and clear HLS track.drm after download

mp4decrypt silently copies files unchanged when the tenc box default KID is all zeros, since none of the real KID:KEY pairs match. Add zero-KID fallback entries to both Widevine and PlayReady mp4decrypt methods, matching what Shaka Packager already does.

Also clear track.drm after HLS download when decryption was performed, preventing unnecessary double-decryption. DASH and URL descriptors already did this.
This commit is contained in:
Andy
2026-03-25 15:06:41 -06:00
parent c930abc6fd
commit b524585d78
3 changed files with 34 additions and 0 deletions
+13
View File
@@ -356,6 +356,19 @@ class PlayReady:
key_hex = key if isinstance(key, str) else key.hex()
key_args.extend(["--key", f"{kid_hex}:{key_hex}"])
# Some services use a blank/zero default KID in the tenc box,
# but the real KID for the license server. Add zero-KID fallback entries so
# mp4decrypt can match when the file's default KID is all zeros.
zero_kid = "00" * 16
existing_kids = {
kid.hex if hasattr(kid, "hex") else str(kid).replace("-", "")
for kid in self.content_keys
}
if zero_kid not in existing_kids:
for key in self.content_keys.values():
key_hex = key if isinstance(key, str) else key.hex()
key_args.extend(["--key", f"{zero_kid}:{key_hex}"])
cmd = [
str(binaries.Mp4decrypt),
"--show-progress",
+13
View File
@@ -290,6 +290,19 @@ class Widevine:
key_hex = key if isinstance(key, str) else key.hex()
key_args.extend(["--key", f"{kid_hex}:{key_hex}"])
# Some services use a blank/zero default KID in the tenc box,
# but the real KID for the license server. Add zero-KID fallback entries so
# mp4decrypt can match when the file's default KID is all zeros.
zero_kid = "00" * 16
existing_kids = {
kid.hex if hasattr(kid, "hex") else str(kid).replace("-", "")
for kid in self.content_keys
}
if zero_kid not in existing_kids:
for key in self.content_keys.values():
key_hex = key if isinstance(key, str) else key.hex()
key_args.extend(["--key", f"{zero_kid}:{key_hex}"])
cmd = [
str(binaries.Mp4decrypt),
"--show-progress",