From 819d4896481c25845a944ce00ece40d7a43b9dfc Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Mon, 21 Aug 2023 00:18:31 -0400 Subject: [PATCH] Improve Resolve export --- auto_editor/edit.py | 4 ++-- auto_editor/formats/fcp11.py | 15 +++++++++++++-- auto_editor/utils/cmdkw.py | 8 ++++---- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/auto_editor/edit.py b/auto_editor/edit.py index 6b672a761..6de310ca3 100644 --- a/auto_editor/edit.py +++ b/auto_editor/edit.py @@ -45,7 +45,7 @@ def set_output( ext_map = { "premiere": ".xml", - "resolve": ".xml", + "resolve": ".fcpxml", "final-cut-pro": ".fcpxml", "shotcut": ".mlt", "json": ".json", @@ -271,7 +271,7 @@ def edit_media( if export["export"] in ("final-cut-pro", "resolve"): from auto_editor.formats.fcp11 import fcp11_write_xml - fcp11_write_xml(export["name"], output, export["export"], tl) + fcp11_write_xml(export["name"], output, export["export"], tl, log) return if export["export"] == "shotcut": diff --git a/auto_editor/formats/fcp11.py b/auto_editor/formats/fcp11.py index e6ec44fd5..a2115bb4b 100644 --- a/auto_editor/formats/fcp11.py +++ b/auto_editor/formats/fcp11.py @@ -8,6 +8,7 @@ from auto_editor.ffwrapper import FileInfo from auto_editor.timeline import TlAudio, TlVideo, v3 + from auto_editor.utils.log import Log """ Export a FCPXML 11 file readable with Final Cut Pro 10.6.8 or later. @@ -40,7 +41,9 @@ def get_colorspace(src: FileInfo) -> str: return "1-1-1 (Rec. 709)" -def fcp11_write_xml(group_name: str, output: str, flavor: str, tl: v3) -> None: +def fcp11_write_xml( + group_name: str, output: str, flavor: str, tl: v3, log: Log +) -> None: def fraction(val: int) -> str: if val == 0: return "0s" @@ -51,8 +54,8 @@ def fraction(val: int) -> str: break proj_name = src.path.stem - tl_dur = tl.out_len() src_dur = int(src.duration * tl.tb) + tl_dur = src_dur if flavor == "resolve" else tl.out_len() fcpxml = Element("fcpxml", version="1.10" if flavor == "resolve" else "1.11") resources = SubElement(fcpxml, "resources") @@ -102,6 +105,7 @@ def fraction(val: int) -> str: else: clips = [] + warn = False for clip in clips: clip_properties = { "name": proj_name, @@ -119,6 +123,7 @@ def fraction(val: int) -> str: # See the "Time Maps" section. # https://developer.apple.com/documentation/professional_video_applications/fcpxml_reference/story_elements/timemap/ + warn = True timemap = SubElement(asset, "timeMap") SubElement(timemap, "timept", time="0s", value="0s", interp="smooth2") SubElement( @@ -129,6 +134,12 @@ def fraction(val: int) -> str: interp="smooth2", ) + if flavor == "resolve" and warn: + log.warning( + "DaVinci Resolve may take a very long time when importing timelines with " + "speed effects. Consider switching to a good editor, like Premiere Pro, " + "Final Cut Pro, or ShotCut (free)" + ) tree = ElementTree(fcpxml) indent(tree, space="\t", level=0) tree.write(output, xml_declaration=True, encoding="utf-8") diff --git a/auto_editor/utils/cmdkw.py b/auto_editor/utils/cmdkw.py index 78d729657..544191620 100644 --- a/auto_editor/utils/cmdkw.py +++ b/auto_editor/utils/cmdkw.py @@ -49,10 +49,6 @@ def __init__(self, name: str, *attrs: cAttr): self.attrs = attrs -def _default_var_f(name: str, val: str, coerce: Any) -> Any: - return coerce(val) - - def _norm_name(s: str) -> str: # Python does not allow - in variable names return s.replace("-", "_") @@ -190,6 +186,10 @@ def go(text: str, c: Any) -> Any: return kwargs +def _default_var_f(name: str, val: str, coerce: Any) -> Any: + return coerce(val) + + def parse_dataclass( text: str, # the string to be parsed build: cAttrs,