perf(drm): decrypt fMP4 segments during download with mp4decrypt

Opt-in decrypt_segments runs mp4decrypt --fragments-info per segment on a thread pool as segments land (DASH, single-init HLS), then decrypts the init alone; hides the post-download decrypt step with byte-identical output.
This commit is contained in:
imSp4rky
2026-08-26 16:27:55 -06:00
parent 8827ffd5cd
commit 89f09f8e84
9 changed files with 425 additions and 72 deletions
+8 -3
View File
@@ -223,6 +223,13 @@ class ClearKeyCENC:
output_size=path.stat().st_size if path.exists() else 0,
)
def mp4decrypt_key_args(self) -> list[str]:
"""Build the mp4decrypt --key arguments for every content key."""
key_args = []
for kid, key in self.content_keys.items():
key_args.extend(["--key", f"{kid.hex}:{key}"])
return key_args
def decrypt_with_mp4decrypt(self, path: Path) -> None:
"""Decrypt using mp4decrypt"""
if not binaries.Mp4decrypt:
@@ -230,9 +237,7 @@ class ClearKeyCENC:
output_path = path.with_stem(f"{path.stem}_decrypted")
key_args = []
for kid, key in self.content_keys.items():
key_args.extend(["--key", f"{kid.hex}:{key}"])
key_args = self.mp4decrypt_key_args()
cmd = [
str(binaries.Mp4decrypt),