DASH: Detect SDH subtitles via AudioPurposeCS:2007=2

This commit is contained in:
rlaphoenix 2024-02-20 19:29:21 +00:00
parent 7f898cf2df
commit b829ea5c5e
1 changed files with 11 additions and 2 deletions

View File

@ -168,8 +168,9 @@ class DASH:
track_type = Subtitle
track_codec = Subtitle.Codec.from_codecs(codecs or "vtt")
track_args = dict(
forced=self.is_forced(adaptation_set),
cc=self.is_closed_caption(adaptation_set)
cc=self.is_closed_caption(adaptation_set),
sdh=self.is_sdh(adaptation_set),
forced=self.is_forced(adaptation_set)
)
elif content_type == "image":
# we don't want what's likely thumbnails for the seekbar
@ -638,6 +639,14 @@ class DASH:
for x in adaptation_set.findall("Role")
)
@staticmethod
def is_sdh(adaptation_set: Element) -> bool:
"""Check if contents of Adaptation Set is for the Hearing Impaired."""
return any(
(x.get("schemeIdUri"), x.get("value")) == ("urn:tva:metadata:cs:AudioPurposeCS:2007", "2")
for x in adaptation_set.findall("Accessibility")
)
@staticmethod
def is_closed_caption(adaptation_set: Element) -> bool:
"""Check if contents of Adaptation Set is a Closed Caption Subtitle."""