Ignore failed parsing of tenc boxes

Some services accidentally (? I presume) mix up the `tenc` box's data with that of an `avc1` box or similar. This causes total failure and crashing. However, in these scenarios there's usually a 2nd box further down the stream that is not an error and will parse correctly. So just skip these errors and continue.
This commit is contained in:
rlaphoenix 2023-04-23 17:38:12 +01:00
parent 86322159b6
commit 630832e434
1 changed files with 7 additions and 0 deletions

View File

@ -16,6 +16,7 @@ from urllib.parse import urlparse
import pproxy
import requests
from construct import ConstError
from langcodes import Language, closest_match
from pymp4.parser import Box
from unidecode import unidecode
@ -146,6 +147,12 @@ def get_boxes(data: bytes, box_type: bytes, as_bytes: bool = False) -> Box:
except IOError:
# TODO: Does this miss any data we may need?
break
except ConstError as e:
if box_type == b"tenc":
# ignore this error on tenc boxes as the tenc definition isn't consistent
# some services don't even put valid data and mix it up with avc1...
continue
raise e
if as_bytes:
box = Box.build(box)
yield box