diff --git a/auto_editor/formats/final_cut_pro.py b/auto_editor/formats/final_cut_pro.py index 047d01425..c0a450d89 100644 --- a/auto_editor/formats/final_cut_pro.py +++ b/auto_editor/formats/final_cut_pro.py @@ -21,7 +21,7 @@ def get_colorspace(src: FileInfo) -> str: # See: https://developer.apple.com/documentation/professional_video_applications/fcpxml_reference/asset#3686496 - if len(src.videos) == 0: + if not src.videos: return "1-1-1 (Rec. 709)" s = src.videos[0] @@ -41,16 +41,11 @@ def get_colorspace(src: FileInfo) -> str: def fcp_xml(group_name: str, output: str, tl: v3) -> None: - # TODOs: - # - Allow fractional timebases - # - Don't hardcode stereo audio layout - - assert int(tl.tb) == tl.tb def fraction(val: int) -> str: if val == 0: return "0s" - return f"{val}/{tl.tb}s" + return f"{val * tl.tb.denominator}/{tl.tb.numerator}s" for _, _src in tl.sources.items(): src = _src @@ -82,7 +77,7 @@ def fraction(val: int) -> str: format="r1", hasAudio="1" if tl.a and tl.a[0] else "0", audioSources="1", - audioChannels="2", + audioChannels=f"{2 if not src.audios else src.audios[0].channels}", duration=fraction(tl_dur), ) SubElement(r2, "media-rep", kind="original-media", src=src.path.resolve().as_uri()) @@ -96,8 +91,8 @@ def fraction(val: int) -> str: format="r1", tcStart="0s", tcFormat="NDF", - audioLayout="stereo", - audioRate=f"{tl.sr // 1000}k", + audioLayout="mono" if src.audios and src.audios[0].channels == 1 else "stereo", + audioRate="44.1k" if tl.sr == 44100 else "48k", ) spine = SubElement(sequence, "spine") diff --git a/auto_editor/preview.py b/auto_editor/preview.py index d4c9afb1d..c34b049c1 100644 --- a/auto_editor/preview.py +++ b/auto_editor/preview.py @@ -26,7 +26,6 @@ def all_cuts(tl: v3, in_len: int) -> list[int]: tb = tl.tb oe: list[tuple[int, int]] = [] - # TODO: Make offset_end_pairs work on overlapping clips. for clip in tl.a[0]: oe.append((clip.offset, clip.offset + clip.dur))