From 96aa7c1e0a09e0440f49b8ff2a1fa3233b7d873b Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Tue, 4 Apr 2023 20:15:18 +0100 Subject: [PATCH] Fix segmented vtt merging code This got 'broken' after moving to my fork of pymp4 because my fork has commits by TrueDread that add support for the vttc, payl, and sttg boxes, therefore they no longer contain `data` fields but rather specifically parsed fields. I also no longer need to parse the data stream of vttc boxes, as they are already parsed as `children`. --- devine/core/tracks/subtitle.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/devine/core/tracks/subtitle.py b/devine/core/tracks/subtitle.py index 7d8d590..b245a06 100644 --- a/devine/core/tracks/subtitle.py +++ b/devine/core/tracks/subtitle.py @@ -315,17 +315,16 @@ class Subtitle(Track): layout: Optional[Layout] = None nodes: list[CaptionNode] = [] - for cue_box in MP4.parse_stream(BytesIO(vttc_box.data)): + for cue_box in vttc_box.children: if cue_box.type == b"vsid": # this is a V(?) Source ID box, we don't care continue - cue_data = cue_box.data.decode("utf8") if cue_box.type == b"sttg": - layout = Layout(webvtt_positioning=cue_data) + layout = Layout(webvtt_positioning=cue_box.settings) elif cue_box.type == b"payl": nodes.extend([ node - for line in cue_data.split("\n") + for line in cue_box.cue_text.split("\n") for node in [ CaptionNode.create_text(WebVTTReader()._decode(line)), CaptionNode.create_break()