From 1754028a148685bf9eee8fe41d868f661e54cb9b Mon Sep 17 00:00:00 2001 From: LightArrowsEXE Date: Fri, 17 Nov 2023 05:39:58 +0100 Subject: [PATCH] WobblyParsed: Convert sections to Keyframes In the eventual setsu rewrite, it would be baller if this were separated into scenechanges and scenefiltering params, as from the top of my head (can't check rn) the other dict item is ranges for specific scenefiltering. --- vsdeinterlace/wobbly/wobbly.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vsdeinterlace/wobbly/wobbly.py b/vsdeinterlace/wobbly/wobbly.py index 153cfa8..b4c00cf 100644 --- a/vsdeinterlace/wobbly/wobbly.py +++ b/vsdeinterlace/wobbly/wobbly.py @@ -43,8 +43,8 @@ class WobblyParsed: decimations: list[int] """A list of decimated frames.""" - scenechanges: Keyframes - """Scenechanges (sections) represented as a Keyframes object.""" + sections: Keyframes + """Sections represented as a Keyframes object.""" timecodes: Timecodes """The timecodes represented as a Timecode object.""" @@ -218,7 +218,7 @@ def parse_wobbly( matches = data.get("matches", []) combs = data.get("combed frames", []) decimations = data.get("decimated frames", []) - sections = data.get("sections", []) + sections = data.get("sections", [{}]) fades = data.get("interlaced fades", []) # TODO: See if we can somehow hack in 60p support. Probably have users set a prop with `presets`? Maybe in `Wibbly`? # presets = data.get("presets", []) @@ -232,6 +232,8 @@ def parse_wobbly( if bool(len(illegal_chars := set(matches) - {*Types.Match.__args__})): # type:ignore[attr-defined] raise CustomValueError(f"Illegal characters found in matches {tuple(illegal_chars)}", parse_wobbly) + sections = Keyframes([section.get("start", 0) for section in sections]) + fades = [(fade.get("frame"), fade.get("field difference")) for fade in (dict(f) for f in fades)] # TODO: timecodes object @@ -251,7 +253,7 @@ def parse_wobbly( combs=list(set(combs) - set([f for f, _ in fades])), orphans=[(o, matches[o]) for o in data.get("orphan frames", [])], # type:ignore[misc] decimations=decimations, - scenechanges=sections, + sections=Keyframes(sections), timecodes=Timecodes(sections), interlaced_fades=fades, freezes=[tuple(freeze) for freeze in data.get("frozen frames", [])] # type:ignore[misc]