Skip to content

Commit

Permalink
DASH: Detect SDH subtitles via AudioPurposeCS:2007=2
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaphoenix committed Feb 20, 2024
1 parent 7f898cf commit b829ea5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions devine/core/manifests/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ def to_tracks(
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
Expand Down Expand Up @@ -638,6 +639,14 @@ def is_forced(adaptation_set: Element) -> bool:
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."""
Expand Down

0 comments on commit b829ea5

Please sign in to comment.