moon_reconform

    Exact-frame audit and transfer of review annotations across hard-cut OpenTimelineIO edits.

    Download zip
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    7 days ago
    Downloads
    18

    #MoonReConform

    MoonReConform 将旧版剪辑上的审阅意见迁移到重剪后的 OpenTimelineIO 工程。剪辑师可以追踪一段意见对应的素材帧,确认重复镜头的目标,或者把缺失素材和旧版空白上的意见留待人工处理。

    #安装与运行

    命令行使用 MoonBit 0.10.20+65efd5b93 和 Node.js 22 或更新版本。复核脚本另需 Python 3.10 或更新版本。在仓库根目录运行以下命令。

    moon update python scripts/verify.py --demo _build/example moon run cmd/main --target js -- plan _build/example/before.otio _build/example/after.otio _build/example/request.json moon run cmd/main --target js -- apply _build/example/before.otio _build/example/after.otio _build/example/request.json _build/example/reviewed.otio

    两条命令都会在标准输出返回 JSON。其中 notes[].pieces 记录旧片段、源素材和所有新候选,held 记录待处理意见的 ID,transfers 记录可写入的片段。示例请求包含两项已确认的候选,最终写入五段标记,保留两条待处理意见。重新运行示例时给生成目录和目标 OTIO 选择新路径。

    #审阅请求

    { "fps": 24, "old_track": 0, "new_track": 1, "notes": [ {"id": "n1", "text": "检查对白入点", "start": 4}, {"id": "n2", "text": "核对转场前的字幕", "start": 3, "stop": 6} ], "selections": [ {"note_id": "n1", "piece": 0, "clip": 3} ] }

    • old_track 和 new_track 是各工程 tracks.children 中从零开始的索引。时间以所选轨道第一帧为 0,各端点为帧号。区间为 [start, stop),省略 stop 表示单帧。
    • 从 plan 的报告确认 ambiguous 片段的候选,将选中的 clip 和该片段在 pieces 中的索引加入 selections,再用同一对 OTIO 文件执行 apply。新轨道中空白也占用子项索引。
    • unique 表示恰有一个新位置,ambiguous 表示两个以上,deleted 表示没有新位置,gap 表示旧位置处于轨道空白。只有一条意见的全部片段解析完毕才会生成标记。有些意见会拆成数个标记,原 ID 和片段序号保存在 metadata.moon_reconform。
    • apply 从输入重新计算,向新工程的选中轨道附加标记。保留现有标记及其余工程字段。目标目录需已存在且支持硬链接,目标文件需为新路径。输入有误、选择无效、标记键冲突或目标已有文件时,命令返回非零退出码。

    #支持边界

    支持两版各选一条启用且未裁剪的 Video 轨道上的硬切,包含 Clip.1、Clip.2 和 Gap.1。使用活动 ExternalReference.1.target_url 的完全匹配作为素材身份,接受共享的整数帧率 1–240,帧号使用可由 JSON 精确表示的非负整数,最大为 2^53−1。素材重命名、变速、效果、转场、嵌套时间线、禁用项、跨帧率和多轨合成超出支持范围。CLI 读取 OTIO 和 JSON 文本,审阅意见由 JSON 请求提供。

    核心将旧意见按镜头边界切分,再按新版本命中区间的端点扫描。素材 URL 索引先定位潜在镜头,再枚举实际覆盖片段的所有新位置,因此长区间无需逐帧扫描。单次分析最多接收每条轨道 20,000 个子项、10,000 条意见,候选查找限额为 1,000,000 次区间检查,报告限额为 100,000 个片段及候选项。

    MoonTimeline 0.2.1 的 otiojson 负责读取与写回 OTIO 数值和未知字段。MoonReConform 提供跨工程的审阅范围映射、歧义确认和迁移报告。MoonTimeline

    #MoonBit 库

    在自己的项目执行 moon add 123123213weqw/moon_reconform@0.1.0,导入包 123123213weqw/moon_reconform。Timeline::from_shots 可接收程序自建的镜头,plan 返回逐段候选,resolve 应用人工确认。纯 MoonBit 核心可在 JS、Wasm、Wasm GC 和 Native 构建。Node CLI 管理文件 I/O。

    #验证

    moon check --target all --deny-warn moon test --target js moon test --target wasm-gc python scripts/verify.py --live-fixture

    复核脚本对 40 组确定种子生成的剪辑和 480 条意见逐帧独立验证。另用固定提交和 SHA-256 的 ElFuente 60 fps 素材时间线生成一次重剪,1430 帧缩减到 1036 帧,5 条意见中迁移 3 条,保留 2 条。复核覆盖选中目标发现、导出范围、已有标记、未知字段和文件冲突,无需下载视频。固定版本的 ElFuente OTIO

    安装 opentimelineio==0.18.1 后,使用 python scripts/verify.py --live-fixture --official-otio 可让官方 Python OpenTimelineIO 读取导出并核对标记范围。

    ReconformError

    pub(all) suberror ReconformError {
    Invalid(String)
    Limit(String)
    }

    Note

    pub(all) struct Note {
    id : String
    text : String
    range : Span
    }

    NoteReport

    pub(all) struct NoteReport {
    note : Note
    pieces : Array[Piece]
    }

    Piece

    pub(all) struct Piece {
    old : Span
    media : String?
    source : Span?
    candidates : Array[Placement]
    kind : PieceKind
    }

    PieceKind

    pub(all) enum PieceKind {
    Unique
    Ambiguous
    Deleted
    GapPiece
    }

    Placement

    pub(all) struct Placement {
    clip : Int
    range : Span
    }

    Request

    pub(all) struct Request {
    fps : Int
    old_track : Int
    new_track : Int
    notes : Array[Note]
    selections : Array[Selection]
    }

    Resolution

    pub(all) struct Resolution {
    transfers : Array[Transfer]
    held : Array[String]
    }

    Selection

    pub(all) struct Selection {
    note_id : String
    piece : Int
    clip : Int
    }

    Shot

    pub(all) enum Shot {
    Clip(String, Span)
    Gap(Int64)
    }

    Span

    pub(all) struct Span {
    start : Int64
    stop : Int64
    }

    Frames use a half-open range [start, stop). Markers use [f, f + 1).

    Span::length

    fn Span::length(self : Span) -> Int64

    Timeline

    pub struct Timeline {
    // private fields
    }

    Timeline::duration

    fn Timeline::duration(self : Timeline) -> Int64

    Timeline::from_shots

    fn Timeline::from_shots(shots : Array[Shot]) -> Timeline raise ReconformError

    Timeline::shot_count

    fn Timeline::shot_count(self : Timeline) -> Int

    Transfer

    pub(all) struct Transfer {
    note_id : String
    text : String
    piece : Int
    placement : Placement
    }

    plan

    fn plan(before : Timeline, after : Timeline, notes : Array[Note]) -> Array[NoteReport] raise ReconformError

    Partition every annotation in old timeline order. Repeated source frames emit all new placements in ascending child-index order.

    read_otio

    fn read_otio(root :
    Json
    , track_index~ : Int, fps~ : Int) -> Timeline raise ReconformError

    Read one untrimmed hard-cut Video track from a Timeline.1.

    read_request

    fn read_request(value :
    Json
    ) -> Request raise ReconformError

    report_json

    fn report_json(before : Timeline, after : Timeline, reports : Array[NoteReport], resolution : Resolution) ->
    Json

    resolve

    fn resolve(reports : Array[NoteReport], selections : Array[Selection]) -> Resolution raise ReconformError

    Resolve whole annotations only. Every unresolved piece holds its annotation back, even when other pieces already have confirmed placements.

    with_markers

    fn with_markers(root :
    Json
    , track_index~ : Int, fps~ : Int, resolution : Resolution) ->
    Json
    raise ReconformError

    Append resolved markers to the new track. The input object is left unchanged.