OpenTimelineIO FCP XML 导入无法找到剪辑

问题描述 投票:0回答:1

我在 Final Cut Pro 和 Adobe Premiere 中有几个视频项目想要转换为 Kdenlive。我找到了 OpenTimelineIO,并通过反复试验并感谢 StackOverflow,得到了以下代码:

import opentimelineio as otio

fp = "/path/to/file/ep4_fixed.fcpxml"
output_fp = fp.replace(".fcpxml", ".kdenlive")
assert fp != output_fp

# Load the FCP XML file
input_otio = otio.adapters.read_from_file(fp)

# Extract the first Timeline from the SerializableCollection
timeline = next((item for item in input_otio if isinstance(item, otio.schema.Timeline)), None)

for item in input_otio:
    if isinstance(item, otio.schema.Timeline):
        print("Timeline found")
        print(item)
    else:
        print("Not a timeline: ", item)

if timeline:
    # Save the timeline as a Kdenlive project
    otio.adapters.write_to_file(timeline, output_fp, adapter_name="kdenlive")
else:
    print("No timeline found in the input file.")

Kdenlive 中的结果表明剪辑的布局和时间码是正确的,但所有剪辑都丢失了:

然而,我手动确认了其中几个剪辑的存在。

XML 文件中的一个示例资源如下,其中包含指向外部驱动器中的剪辑的链接:

        <asset id="r117" name="Duck" uid="8E011DED69D190CFE0018A6D24E90A31" start="0s" duration="518344/44100s" hasAudio="1" audioSources="1" audioChannels="2" audioRate="44100">
            <media-rep kind="original-media" sig="8E011DED69D190CFE0018A6D24E90A31" src="file:///Volumes/Video/BulgyPT.fcpbundle/ep1-6/Original%20Media/Duck.mp3">
                <bookmark>Ym9va8AEA...EAAAAAAAAAA==</bookmark>
            </media-rep>
            <metadata>
                <md key="com.apple.proapps.mio.ingestDate" value="2020-07-05 18:19:58 +0100"/>
            </metadata>
        </asset>

print(item)
行中该资产的对应项目是:

otio.schema.Clip(name='Duck', media_reference=otio.schema.MissingReference(name='', available_range=None, available_image_bounds=None, metadata={}), source_range=otio.opentime.TimeRange(start_time=otio.opentime.RationalTime(value=0, rate=25), duration=otio.opentime.RationalTime(value=170, rate=25)), metadata={})

因此 OpenTimelineIO 适配器找不到任何资产的文件。

我尝试用空格替换 HTML 实体,例如

%20
,但得到了相同的结果。

这里是导致此错误的完整 FCP XML 文件的 Dropbox 链接

如何调整 XML 文件或对代码进行猴子修补以在外部驱动器中找到这些剪辑?

注意:这是一个后续问题,与 Monkey-patching OpenTimelineIO 适配器导入 Final Cut Pro XML使用 Kdenlive 适配器导出 Final Cut Pro 文件时出现 OpenTimelineIO 错误不同。

python python-3.x xml finalcut
1个回答
0
投票

打印的

otio.schema.MissingReference
对象中的
otio.schema.Clip
表示 OTIO 无法找到 FCP XML 中引用的媒体文件。

该问题可能是由于不同应用程序解释文件路径的方式存在差异,特别是当文件存储在外部驱动器上或路径包含 URL 编码字符的位置时(例如

%20
表示空格)。此外,FCP XML 文件中的原始媒体路径是绝对的,如果环境或文件系统结构不同(例如,在操作系统之间移动或驱动器安装点更改时),则可能无法直接解析路径OTIOKdenlive

一种简单但手动的方法是调整 FCP XML 文件中的路径,以正确指向媒体文件在系统上的当前位置。这可能涉及用空格替换

%20
并确保路径对于当前文件系统布局来说是正确的。但这对于具有许多文件的大型项目来说是不切实际的。

更具可扩展性的解决方案涉及编写 Python 脚本,以便在导出到 Kdenlive 之前以编程方式调整 OTIO 对象中的媒体文件路径。您可以遍历 OTIO 对象的层次结构,使用

Clip
媒体引用识别
MissingReference
对象,并将其替换为有效路径(OTIO 适配器)。

import opentimelineio as otio
import urllib.parse

def fix_media_references(timeline, base_path):
    for clip in timeline.each_clip():
        if isinstance(clip.media_reference, otio.schema.MissingReference):
            original_src = clip.name  # Assuming the clip name holds the original file name
            new_path = urllib.parse.unquote(base_path + original_src)
            clip.media_reference = otio.schema.ExternalReference(target_url=new_path)

base_media_path = "/path/to/media/files/" 

# Load the timeline from FCP XML
timeline = otio.adapters.read_from_file("path/to/fcpxml")

# Fix the media references
fix_media_references(timeline, base_media_path)

# Export the fixed timeline to Kdenlive
otio.adapters.write_to_file(timeline, "output_path.kdenlive", adapter_name="kdenlive")

确保您的媒体文件可由软件访问和读取(权限、文件系统访问等)。有时,问题也可能源于外部驱动器未安装在同一位置或跨会话或操作系统使用相同的驱动器号/名称。

© www.soinside.com 2019 - 2024. All rights reserved.