OpenMontage 架构¶
最后更新:2026-03-28 | 源自代码探索,而非先前文档。
OpenMontage 是一个智能体编排的视频制作平台。LLM 编码助手(Claude Code、Cursor、Copilot 等)充当编排器——读取流水线清单、遵循技能指令、调用 Python 工具并保存检查点状态。运行时没有 Python 编排器;智能体_就是_控制平面。
高层流程¶
User gives topic/idea
|
v
Agent reads pipeline manifest (YAML)
|
v
For each stage:
1. Agent reads stage-director skill (Markdown)
2. Agent calls Python tools via tool registry
3. Agent writes checkpoint (JSON) with artifacts
4. Agent self-reviews using meta/reviewer skill
5. Human approval gate (if configured)
|
v
Final video output
仓库布局¶
OpenMontage/
├── lib/ # Core runtime infrastructure (Python)
│ ├── config_model.py # Pydantic config: LLM, budget, checkpoint, output, paths
│ ├── checkpoint.py # Pipeline state persistence & stage transitions
│ ├── pipeline_loader.py # YAML manifest loading & validation
│ ├── media_profiles.py # Platform-specific render profiles (YouTube, TikTok, etc.)
│ ├── env_loader.py # .env variable management
│ └── providers/ # (Reserved for future provider abstractions)
│
├── tools/ # 57+ Python tool implementations
│ ├── base_tool.py # Abstract base class — the tool contract
│ ├── tool_registry.py # Auto-discovery singleton registry
│ ├── cost_tracker.py # Budget governance (estimate → reserve → reconcile)
│ ├── analysis/ # Transcription, scene detection, frame sampling, video understanding
│ ├── audio/ # TTS (ElevenLabs, OpenAI, Piper, Azure, Google), music gen, mixing, enhancement
│ ├── avatar/ # Talking head animation, lip sync
│ ├── enhancement/ # Upscale, bg removal, face enhance/restore, color grading
│ ├── graphics/ # Image gen (FLUX, GPT Image, Recraft, local diffusion), stock, diagrams, code snippets, math animation
│ ├── publishers/ # (Reserved)
│ ├── subtitle/ # SRT/VTT generation from timestamps
│ └── video/ # 13 video gen providers, composition, stitching, trimming
│
├── pipeline_defs/ # YAML pipeline manifests
├── schemas/ # JSON Schema definitions for validation
│ ├── artifacts/ # 11 artifact schemas (brief → publish_log)
│ ├── checkpoints/ # Checkpoint state schema
│ ├── pipelines/ # Pipeline manifest schema
│ ├── styles/ # Style playbook schema
│ └── tools/ # Tool-specific schemas
│
├── skills/ # Layer 2: OpenMontage-specific agent instructions
│ ├── core/ # FFmpeg, Remotion, WhisperX, color grading skills
│ ├── creative/ # Video editing, enhancement, data viz, prompt engineering
│ ├── meta/ # reviewer, checkpoint-protocol, skill-creator
│ └── pipelines/ # Per-pipeline stage-director skills
│
├── .agents/skills/ # Layer 3: external technology skills (FFmpeg, HyperFrames, GSAP, etc.)
├── styles/ # Visual style playbooks (YAML) + loader
├── remotion-composer/ # Node.js/React — Remotion video composition renderer
├── tests/ # Contract tests, QA integration tests, eval harness
├── docs/ # Best-practices guides, session handoffs, audits
└── config.yaml # Global runtime configuration
核心架构原则¶
1. 智能体优先编排¶
这里没有 Python 编排器。LLM 智能体: - 读取流水线清单以了解阶段顺序 - 读取每个阶段的导演技能以获取详细指令 - 调用工具、评估结果并做出创意决策 - 写入检查点以在阶段之间持久化状态
Python 仅提供工具与持久化。所有智能都存在于技能指令(Markdown)和流水线清单(YAML)中。
2. 运行时无需 LLM API Key¶
OpenMontage 在运行时不会调用 LLM API。运行在用户 IDE 中的编码助手_就是_LLM。需要生成能力(图像、视频、TTS)的工具直接调用领域专用 API(ElevenLabs、fal.ai、HeyGen 等),而非通用 LLM 端点。
3. 双提供商支持¶
每项能力都必须同时支持 API 提供商(云端、付费)和本地/开源替代方案(免费、依赖 GPU)。选择器模式通过路由到可用选项来强制执行这一要求。
工具系统¶
BaseTool 契约¶
所有工具都继承自 BaseTool(ABC)并声明:
| 字段 | 用途 |
|---|---|
name, version |
标识 |
tier |
CORE、VOICE、ENHANCE、GENERATE、SOURCE、ANALYZE、PUBLISH |
capability |
功能(例如 tts、image_generation、video_post) |
provider |
提供商(例如 elevenlabs、ffmpeg、selector) |
runtime |
LOCAL、LOCAL_GPU、API、HYBRID |
stability |
EXPERIMENTAL、BETA、PRODUCTION |
dependencies |
所需的二进制文件(cmd:ffmpeg)、环境变量(env:ELEVENLABS_API_KEY)、Python 包(python:torch) |
input_schema, output_schema |
输入/输出的 JSON Schema |
fallback_tools |
有序回退链 |
agent_skills |
指向第 3 层知识技能的链接 |
resource_profile |
CPU、RAM、VRAM、磁盘、网络要求 |
retry_policy |
最大重试次数、退避策略 |
必需方法: execute(inputs) -> ToolResult
ToolResult 携带:success、data、artifacts(文件路径)、error、cost_usd、duration_seconds、seed、model。
工具注册表¶
ToolRegistry 是一个单例,通过 pkgutil.walk_packages() 自动发现所有 BaseTool 子类。无需手动注册。
关键查询:
get_by_capability("tts")— 所有 TTS 工具get_by_provider("elevenlabs")— 所有 ElevenLabs 工具get_available()— 依赖已满足的工具find_fallback("elevenlabs_tts")— 解析回退链support_envelope()— 供智能体使用的完整能力报告gpu_required_tools()、network_required_tools()
选择器模式¶
三个选择器工具抽象了多提供商的能力:
| 选择器 | 能力 | 选择机制 |
|---|---|---|
tts_selector |
文本转语音(TTS) | 按任务匹配度、质量、可控性、可靠性、成本、延迟和连续性对发现的提供商进行排名 |
image_selector |
图像生成 | 从实时注册表中对发现的提供商进行排名;没有硬编码的提供商顺序 |
video_selector |
视频生成 | 从实时注册表中对发现的提供商进行排名;在用户明确提供偏好时予以尊重 |
atlas_image / atlas_video |
Atlas Cloud 生成 | 为图像生成/编辑以及文本/图像/参考/视频编辑生成提供精确的逐模型路由目录 |
选择器的路由依据是:用户明确设置的偏好,其次是对可用提供商的评分排名。它们会在提供商之间透明地适配输入模式。
按类别划分的工具清单¶
分析(5): transcriber (WhisperX), azure_stt, scene_detect, frame_sampler, video_understand (CLIP/BLIP-2)
音频(9): elevenlabs_tts, google_tts, openai_tts, piper_tts, azure_tts, tts_selector, music_gen, audio_mixer, audio_enhance
虚拟形象(2): talking_head (SadTalker/MuseTalk), lip_sync (Wav2Lip)
增强(5): upscale (Real-ESRGAN), bg_remove (rembg/U2Net), face_enhance, face_restore (CodeFormer/GFPGAN), color_grade (FFmpeg LUTs)
图形(13): flux_image, grok_image, google_imagen, openai_image, recraft_image, local_diffusion, pexels_image, pixabay_image, image_selector, code_snippet, diagram_gen, math_animate (ManimCE), image_gen (已弃用)
字幕(1): subtitle_gen
视频(18): grok_video, heygen_video, higgsfield_video, veo_video, kling_video, runway_video, minimax_video, wan_video, hunyuan_video, cogvideo_video, ltx_video_local, ltx_video_modal, pexels_video, pixabay_video, video_selector, video_compose (FFmpeg), video_stitch, video_trimmer
流水线系统¶
流水线清单¶
每个流水线都是 pipeline_defs/ 中的一个 YAML 文件,用于定义:
name: animated-explainer
version: "2.0"
category: generated # talking_head | generated | hybrid | screen_recording | animation | cinematic | custom
default_checkpoint_policy: guided
orchestration:
mode: executive-producer
skill: pipelines/explainer/executive-producer
budget_default_usd: 2.00
max_revisions_per_stage: 3
compatible_playbooks:
- clean-professional
- flat-motion-graphics
stages:
- name: research
skill: pipelines/explainer/research-director
produces: [research_brief]
tools_available: []
checkpoint_required: false
human_approval_default: false
review_focus: [...]
success_criteria: [...]
# ... through publish
可用的流水线¶
| 流水线 | 类别 | 描述 |
|---|---|---|
animated-explainer |
generated | AI 生成的解说视频,包含研究、旁白、视觉和音乐 |
animation |
animation | 动态图形、动态排版 |
avatar-spokesperson |
talking_head | 由虚拟形象驱动的演示视频 |
character-animation |
animation | 使用 SVG 骨架、姿势库、GSAP 时间线和 HyperFrames 渲染的本地绑定卡通角色 |
cinematic |
cinematic | 预告片、宣传片、情绪驱动的剪辑 |
clip-factory |
custom | 从长视频源批量生成短视频片段 |
hybrid |
hybrid | 原始素材 + AI 生成的辅助视觉 |
localization-dub |
custom | 为现有视频添加字幕、配音和翻译 |
podcast-repurpose |
hybrid | 将播客亮点转为视频 |
screen-demo |
screen_recording | 软件屏幕录制和操作演示 |
talking-head |
talking_head | 以素材为主的演讲者视频 |
framework-smoke |
custom | 用于框架验证的最小冒烟测试 |
标准阶段推进¶
大多数生产流水线遵循标准的 8 阶段流程:
每个阶段: 1. 拥有一个 阶段导演技能(面向代理的 Markdown 指令) 2. 声明 tools_available(代理可以调用的工具) 3. 生成一个或多个规范产物 4. 具有 review_focus 标准和 success_criteria 标准 5. 可以要求在继续之前获得人工审批
专业流水线可以插入特定领域的阶段。例如,
character-animation 会在 scene_plan 之前添加 character_design 和 rig_plan,
然后在 projects/<project-name>/renders/final.mp4 输出 HyperFrames 工作区和最终交付物。
检查点系统¶
检查点将流水线状态以 JSON 形式持久化存储在项目的 pipeline/ 目录中。
{
"version": "1.0",
"project_id": "my-video",
"stage": "script",
"status": "completed",
"timestamp": "2026-03-28T10:00:00Z",
"checkpoint_policy": "guided",
"human_approval_required": false,
"human_approved": true,
"artifacts": { "script": { ... } },
"review": { ... },
"cost_snapshot": { ... }
}
状态值: pending | in_progress | awaiting_human | completed | failed
检查点策略:
- guided — 在关键创意阶段设置检查点,在机械性阶段自动继续
- manual_all — 每个阶段都需要人工审批
- auto_noncreative — 除非阶段是创意性的(assets、edit),否则自动继续
函数: write_checkpoint(), read_checkpoint(), get_latest_checkpoint(), get_completed_stages(), get_next_stage()
规范产物(11 种类型,全部经过 JSON-schema 验证)¶
| 产物 | 阶段 | 内容 |
|---|---|---|
research_brief |
research | 全局分析、数据点、受众洞察、角度 |
proposal_packet |
proposal | 概念选项、制作计划、成本估算、审批关卡 |
brief |
idea | 标题、钩子、要点、基调、风格、平台、时长 |
script |
script | 带时间戳的段落、增强提示、发音指南 |
scene_plan |
scene_plan | 场景定义,包含类型、描述、时间安排 |
asset_manifest |
assets | 生成的资产,包含路径、来源工具、场景关联 |
edit_decisions |
edit | 含入点/出点时长的剪辑决策 |
render_report |
compose | 输出元数据(格式、分辨率、时长) |
publish_log |
publish | 带状态的平台发布记录 |
review |
(任意) | 审阅者反馈与审批记录 |
cost_log |
(任意) | 预算跟踪条目 |
预算治理¶
CostTracker 在整个流水线中执行支出控制。
生命周期¶
estimate(tool, operation, $) → entry_id
|
reserve(entry_id) # locks budget
|
reconcile(entry_id, $) # records actual spend
预算模式¶
| 模式 | 行为 |
|---|---|
observe |
仅跟踪成本,不强制执行 |
warn |
超支时记录警告,允许继续执行 |
cap |
拒绝超出剩余预算的操作 |
控制项¶
- 总预算(默认:$10.00)
- 预留缓冲(默认:10%)— 作为安全余量保留
- 单次操作审批阈值(默认:$0.50)— 超过此金额需暂停等待审批
- 新付费工具审批 — 首次使用任何付费工具需确认
- 按项目持久化至
cost_log.json
三层知识架构¶
Layer 3: .agents/skills/ External technology knowledge (47 skills)
"How the technology works" FFmpeg, ElevenLabs API, FLUX, Remotion, Three.js, etc.
^
| agent_skills[] references
|
Layer 2: skills/ OpenMontage conventions
"How this project uses the tech" Pipeline integration, quality checklists, artifact mappings
^
| stage skill references
|
Layer 1: tools/ + pipeline_defs/ Executable capabilities + orchestration definitions
"What exists and when to use it" BaseTool contracts, pipeline manifests
每个工具的 agent_skills[] 字段将第 1 层与第 2 层和第 3 层连接起来。例如:
- video_compose.agent_skills = ["remotion-best-practices", "remotion", "ffmpeg"]
- tts_selector.agent_skills = ["text-to-speech", "elevenlabs", "openai-docs"]
配置¶
config.yaml¶
llm:
provider: anthropic
temperature: 0.7
max_tokens: 4096
budget:
mode: warn
total_usd: 10.00
reserve_pct: 0.10
single_action_approval_usd: 0.50
checkpoint:
policy: guided
storage_dir: pipeline
output:
default_format: mp4
default_codec: libx264
default_audio_codec: aac
default_resolution: 1920x1080
default_fps: 30
default_crf: 23
paths:
pipeline_dir: pipeline
library_dir: library
styles_dir: styles
skills_dir: skills
output_dir: output
所有配置均通过 lib/config_model.py 中的 Pydantic 模型进行校验。
环境变量(.env)¶
| 变量 | 使用方 | 用途 |
|---|---|---|
ELEVENLABS_API_KEY |
elevenlabs_tts, music_gen | TTS、音乐、音效 |
AZURE_SPEECH_KEY + AZURE_SPEECH_REGION |
azure_stt, azure_tts | Azure AI Speech 云端转写 + 神经 TTS(同一资源,双向使用) |
OPENAI_API_KEY |
openai_tts, openai_image | TTS 备用、GPT Image 2 |
XAI_API_KEY |
grok_image, grok_video | Grok 图像编辑/生成、Grok 视频生成 |
FAL_KEY |
flux_image, kling_video, veo_video, minimax_video, recraft_image | fal.ai 托管的模型(FLUX、Veo、Kling、MiniMax、Recraft) |
KLING_API_KEY |
kling_official_video, kling_official_image, kling_tts, kling_avatar, kling_lip_sync | Kling Official 直连 API,用于视频、图像、TTS、数字人和唇形同步 |
KLING_API_BASE_URL |
kling_official_video, kling_official_image, kling_tts, kling_avatar, kling_lip_sync | 可选的 Kling Official API 端点覆盖 |
HEYGEN_API_KEY |
heygen_video | 多提供商视频生成 |
PEXELS_API_KEY |
pexels_image, pexels_video | 素材库媒体 |
PIXABAY_API_KEY |
pixabay_image, pixabay_video | 素材库媒体 |
GOOGLE_API_KEY |
google_imagen, google_tts | Google Imagen 图像、Google Cloud TTS |
RUNWAY_API_KEY |
runway_video | Runway Gen-3/Gen-4 直连 |
HIGGSFIELD_API_KEY + HIGGSFIELD_API_SECRET |
higgsfield_video | Higgsfield 多模型视频 |
MODAL_LTX2_ENDPOINT_URL |
ltx_video_modal | 自托管 LTX-2 |
VIDEO_GEN_LOCAL_ENABLED |
local video tools | 启用本地 GPU 生成 |
VIDEO_GEN_LOCAL_MODEL |
wan, hunyuan, ltx, cogvideo | 选择本地模型 |
Kling Official 支持仍保留在现有的提供商与能力模型之内。
kling_official_video 和 kling_official_image 处理 Classic、Turbo 和 Omni 请求形态,而 Elements 和 Account Usage 位于 tools/_kling/ 下,作为元素 ID 引用和低频账户诊断的内部辅助工具;它们不是独立的流水线阶段、选择器或生成资产能力。
Kling Official 仅在 OpenMontage 已有匹配能力位置时添加提供商工具:kling_tts 对应 tts,kling_avatar 和 kling_lip_sync 对应 avatar。Kling Official 音频特效和视频特效未注册为工具,因为当前流水线未定义稳定的 sound_effects 或 video_effects 能力路由。
视觉风格系统¶
styles/ 中的风格手册定义了流水线的视觉语言:
clean-professional.yaml— 企业级精致外观flat-motion-graphics.yaml— 现代扁平设计minimalist-diagram.yaml— 技术型极简图表
由 styles/playbook_loader.py 加载。每个流水线在其清单中声明 compatible_playbooks,并依据 schemas/styles/playbook.schema.json 进行校验。
媒体配置文件¶
lib/media_profiles.py 中的平台专用渲染配置:
| 配置文件 | 分辨率 | 宽高比 | 说明 |
|---|---|---|---|
youtube_landscape |
1920x1080 | 16:9 | 标准 YouTube |
youtube_4k |
3840x2160 | 16:9 | 4K YouTube |
youtube_shorts |
1080x1920 | 9:16 | 最长 60 秒 |
instagram_reels |
1080x1920 | 9:16 | 最长 90 秒 |
instagram_feed |
1080x1080 | 1:1 | 正方形 |
tiktok |
1080x1920 | 9:16 | 竖屏 |
linkedin |
1920x1080 | 16:9 | 横屏 |
cinematic |
2560x1080 | 21:9 | 超宽屏 |
每个配置都指定了编码器、音频编码器、CRF、像素格式、最大文件大小、最大时长和字幕格式。ffmpeg_output_args(profile) 会生成相应的 FFmpeg 参数。
合成运行时¶
OpenMontage 具有多运行时合成层。三个引擎位于 video_compose 之后,在提案阶段选定并锁定在 edit_decisions.render_runtime 中:
Remotion(基于 React)¶
remotion-composer/ 中一个独立的 Node.js/React 子项目,使用 Remotion。
- React 18 + Remotion 4.0 + TypeScript 5.3
- 处理现有的场景组件栈(
text_card、stat_card、图表、字幕、TalkingHead、CinematicRenderer) - 脚本:
start(Studio)、build(渲染)、upgrade(升级)
HyperFrames(HTML/CSS/GSAP)¶
通过 npx hyperframes 使用(无需检出 monorepo)。运行时最低要求:Node.js ≥ 22、FFmpeg、npx。
- 负责动态排印、产品宣传片、发布短视频、网站转视频、注册表块以及 SVG/GSAP 角色绑定
- 驱动:
tools/video/hyperframes_compose.py在projects/<name>/hyperframes/下生成工作区,然后运行lint → validate → render - Layer 3 技能位于
.agents/skills/hyperframes*/;Layer 2 指南位于skills/core/hyperframes.md character-animation流水线使用 HyperFrames 作为生产渲染包。浏览器预览只是 QA/调试产物,不是渲染路径。
FFmpeg(后备 / 简单剪辑)¶
- 在不需要合成时处理纯 concat/trim(拼接/裁剪)
- 也将字幕烧录作为事后操作处理
video_compose 读取 edit_decisions.render_runtime,并通过 _render_via_hyperframes、_remotion_render 或 _render_via_ffmpeg 进行分发。禁止静默替换运行时——当所选运行时不可用时,工具会返回一个结构化的阻塞项(blocker)。完整决策矩阵请参阅 AGENT_GUIDE.md → "Composition Runtimes (Inside video_compose)" 和 skills/core/hyperframes.md。
测试架构¶
tests/
├── contracts/ # Phase 0-3: tool contract validation, schema checks, registry tests
├── qa/ # Integration tests: TTS, image gen, music, audio mix, video compose/stitch, E2E
├── eval/ # Golden scenario replay harness for regression testing
├── pipelines/ # Pipeline-level tests
├── tools/ # Individual tool tests
└── styles/ # Style playbook tests
契约测试验证每个工具是否满足 BaseTool 契约:身份字段、schema、依赖声明、继承。
QA 测试调用真实工具(使用真实 API/二进制文件)并检查输出质量。
Eval 测试框架(tests/eval/replay_harness/)重放黄金场景,并针对随机输出进行基于容差的比较。
系统依赖¶
必需: - Python >= 3.10 - FFmpeg(约 15 个工具使用)
可选(扩展能力): - Node.js(用于 Remotion composer) - GPU + CUDA(用于本地视频/图像生成) - Piper(离线 TTS) - ManimCE(数学动画) - Mermaid CLI(图表生成)
Python 包: pyyaml、pydantic、jsonschema、python-dotenv(核心);pytest、pytest-asyncio(开发);torch、torchvision、torchaudio(GPU)
关键设计决策¶
-
无运行时编排器——LLM 智能体读取 YAML 和 Markdown 并驱动一切。这使得系统可调试(只需阅读技能)且与模型无关。
-
基于检查点的恢复——任何阶段都可能失败,流水线会从最后一个检查点恢复,无需重跑已完成阶段。
-
Schema 校验的产物——每个阶段的输出在写入检查点之前都会根据 JSON Schema 进行校验,防止垃圾数据传播。
-
预算是一等概念——执行前进行成本估算、预算预留和对账。智能体无法静默超支。
-
选择器模式而非硬编码提供商——能力会优雅降级。缺少某个 API key?选择器会回退到下一个提供商或本地替代方案。
-
用技能而非代码承载智能——创意决策、质量检查清单、评审标准和提示词模板都存在于 Markdown 技能中,而不是 Python 代码中。这意味着只需编辑文本文件而不是代码,就可以调整智能体的行为。
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 op/OpenMontage