Skip to content

Commit

Permalink
Improve Resolve export
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Aug 21, 2023
1 parent 00b539d commit 819d489
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions auto_editor/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def set_output(

ext_map = {
"premiere": ".xml",
"resolve": ".xml",
"resolve": ".fcpxml",
"final-cut-pro": ".fcpxml",
"shotcut": ".mlt",
"json": ".json",
Expand Down Expand Up @@ -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":
Expand Down
15 changes: 13 additions & 2 deletions auto_editor/formats/fcp11.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"
Expand All @@ -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")
Expand Down Expand Up @@ -102,6 +105,7 @@ def fraction(val: int) -> str:
else:
clips = []

warn = False
for clip in clips:
clip_properties = {
"name": proj_name,
Expand All @@ -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(
Expand All @@ -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")
8 changes: 4 additions & 4 deletions auto_editor/utils/cmdkw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("-", "_")
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 819d489

Please sign in to comment.