Failed to parse encrypted mp4 without "subsample_encryption_info" inside 'senc' box
ktp420 opened this issue · 0 comments
ktp420 commented
When trying to parse encrypted mp4 that only has 'iv' in 'sample_encryption_info' array inside 'SampleEncryptionBox', i.e. 'senc' type, then parser fails with following exception because the If condition is trying to look for 'flags' inside the 'sample_encryption_info' struct instade of the parrent struct 'SampleEncryptionBox'.
Traceback (most recent call last):
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 1089, in _parse
return list(self.subcon._parse(stream, context, path) for i in range(count))
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 1089, in <genexpr>
return list(self.subcon._parse(stream, context, path) for i in range(count))
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 859, in _parse
subobj = sc._parse(stream, context, path)
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 2696, in _parse
return self.subcon._parse(stream, context, path)
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 297, in _parse
return self.subcon._parse(stream, context, path)
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 1543, in _parse
key = self.keyfunc(context) if callable(self.keyfunc) else self.keyfunc
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 1581, in <lambda>
lambda ctx: bool(predicate(ctx)),
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/expr.py", line 145, in __call__
context2 = self.__parent(context)
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/expr.py", line 146, in __call__
return context2[self.__name]
KeyError: 'flags'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 2696, in _parse
return self.subcon._parse(stream, context, path)
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 1093, in _parse
raise RangeError("could not read prefix or enough elements, stream too short?")
construct.core.RangeError: could not read prefix or enough elements, stream too short?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ktp420/.venv/pywidevine/bin/mp4dump", line 8, in <module>
sys.exit(dump())
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/pymp4/cli.py", line 26, in dump
box = Box.parse_stream(fd)
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 186, in parse_stream
return self._parse(stream, context, "parsing")
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/pymp4/parser.py", line 46, in _parse
obj = self.subcon._parse(stream2, context, path)
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 855, in _parse
subobj = list(sc._parse(stream, context, path).items())
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 297, in _parse
return self.subcon._parse(stream, context, path)
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 1544, in _parse
obj = self.cases.get(key, self.default)._parse(stream, context, path)
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 859, in _parse
subobj = sc._parse(stream, context, path)
File "/home/ktp420/.venv/pywidevine/lib/python3.10/site-packages/construct/core.py", line 2700, in _parse
raise e.__class__("%s\n %s" % (e, path))
construct.core.RangeError: could not read prefix or enough elements, stream too short?
parsing -> sample_encryption_info