Skip to content

Commit

Permalink
Use fcp11 for resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Aug 21, 2023
1 parent bad3ba0 commit 00b539d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
10 changes: 5 additions & 5 deletions auto_editor/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,16 @@ def edit_media(
make_json_timeline(export["api"], output, tl, log)
return

if export["export"] in ("premiere", "resolve"):
if export["export"] == "premiere":
from auto_editor.formats.fcp7 import fcp7_write_xml

fcp7_write_xml(export["name"], ffmpeg, output, tl, export["export"], log)
fcp7_write_xml(export["name"], ffmpeg, output, tl, log)
return

if export["export"] == "final-cut-pro":
from auto_editor.formats.final_cut_pro import fcp_xml
if export["export"] in ("final-cut-pro", "resolve"):
from auto_editor.formats.fcp11 import fcp11_write_xml

fcp_xml(export["name"], output, tl)
fcp11_write_xml(export["name"], output, export["export"], tl)
return

if export["export"] == "shotcut":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_colorspace(src: FileInfo) -> str:
return "1-1-1 (Rec. 709)"


def fcp_xml(group_name: str, output: str, tl: v3) -> None:
def fcp11_write_xml(group_name: str, output: str, flavor: str, tl: v3) -> None:
def fraction(val: int) -> str:
if val == 0:
return "0s"
Expand All @@ -54,7 +54,7 @@ def fraction(val: int) -> str:
tl_dur = tl.out_len()
src_dur = int(src.duration * tl.tb)

fcpxml = Element("fcpxml", version="1.11")
fcpxml = Element("fcpxml", version="1.10" if flavor == "resolve" else "1.11")
resources = SubElement(fcpxml, "resources")
SubElement(
resources,
Expand Down
17 changes: 6 additions & 11 deletions auto_editor/formats/fcp7.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,6 @@ def xml_bool(val: str) -> bool:
return v3(sources, tb, sr, res, "#000", vobjs, aobjs, None)


def path_resolve(path: Path, flavor: str) -> str:
if flavor == "resolve":
return path.resolve().as_uri()
return f"{path.resolve()}"


def media_def(
filedef: Element, url: str, src: FileInfo, tl: v3, tb: int, ntsc: str
) -> None:
Expand Down Expand Up @@ -379,9 +373,7 @@ def media_def(
ET.SubElement(audiodef, "channelcount").text = f"{src.audios[0].channels}"


def fcp7_write_xml(
name: str, ffmpeg: FFmpeg, output: str, tl: v3, flavor: str, log: Log
) -> None:
def fcp7_write_xml(name: str, ffmpeg: FFmpeg, output: str, tl: v3, log: Log) -> None:
width, height = tl.res
timebase, ntsc = set_tb_ntsc(tl.tb)

Expand All @@ -390,10 +382,13 @@ def fcp7_write_xml(
key_to_source: dict[tuple[str, int], FileInfo] = {}
file_defs: set[str] = set() # Contains urls

def path_resolve(path: Path) -> str:
return f"{path.resolve()}"

for key, src in tl.sources.items():
key_to_source[(key, 0)] = src
key_to_id[(key, 0)] = f"file-{len(key_to_id)+1}"
key_to_url[(key, 0)] = path_resolve(src.path, flavor)
key_to_url[(key, 0)] = path_resolve(src.path)

if len(src.audios) > 1:
fold = src.path.parent / f"{src.path.stem}_tracks"
Expand All @@ -407,7 +402,7 @@ def fcp7_write_xml(
)

key_to_source[(key, i)] = FileInfo(f"{newtrack}", ffmpeg, log, key)
key_to_url[(key, i)] = path_resolve(newtrack, flavor)
key_to_url[(key, i)] = path_resolve(newtrack)
key_to_id[(key, i)] = f"file-{len(key_to_id)+1}"

xmeml = ET.Element("xmeml", version="4")
Expand Down

0 comments on commit 00b539d

Please sign in to comment.