We can now extract the PSSH box from the initalization mp4 to get the Key ID for decryption. Also added re-enabled decryption

This commit is contained in:
Puyodead1
2021-05-18 15:39:04 -04:00
parent 8d41a494c9
commit e97909ddca
4 changed files with 684 additions and 9 deletions

32
utils.py Normal file
View File

@@ -0,0 +1,32 @@
import mp4parse
import codecs
import widevine_pssh_pb2
import base64
def extract_kid(mp4_file):
"""
Parameters
----------
mp4_file : str
MP4 file with a PSSH header
Returns
-------
String
"""
boxes = mp4parse.F4VParser.parse(filename=mp4_file)
for box in boxes:
if box.header.box_type == 'moov':
pssh_box = next(x for x in box.pssh if x.system_id == "edef8ba979d64acea3c827dcd51d21ed")
hex = codecs.decode(pssh_box.payload, "hex")
pssh = widevine_pssh_pb2.WidevinePsshData()
pssh.ParseFromString(hex)
content_id = base64.b16encode(pssh.content_id)
return content_id.decode("utf-8")
# No Moof or PSSH header found
return None