mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-27 11:25:08 +00:00
fix(subtitles): accept TTML2 rw/rh and vw/vh sizes in fTTML conversion
pycaption rejects these units on extent/origin/padding, which failed every STPP track that uses them; rewrite them to % before parsing.
This commit is contained in:
@@ -752,6 +752,11 @@ class Subtitle(Track):
|
||||
elif codec == Subtitle.Codec.TimedTextMarkupLang:
|
||||
text = try_ensure_utf8(data).decode("utf8")
|
||||
text = text.replace("tt:", "")
|
||||
text = re.sub(
|
||||
r"tts:(?:extent|origin|padding)=(\"[^\"]*\"|'[^']*')",
|
||||
lambda m: re.sub(r"(?<=\d)[vr][wh]\b", "%", m[0]),
|
||||
text,
|
||||
)
|
||||
# negative size values aren't allowed in TTML/DFXP spec, replace with 0
|
||||
text = re.sub(r"-(\d+(?:\.\d+)?)(px|em|%|c|pt)", r"0\2", text)
|
||||
caption_set = pycaption.DFXPReader().read(text)
|
||||
|
||||
Reference in New Issue
Block a user