Opus Motion 动效库
根目录:此仓库克隆到的文件夹,或当前宿主项目中的副本。先阅读其中的 AGENTS.md — 它包含了决策流程、图层分层规则、Web 性能规则和反模式。然后阅读 docs/CHOOSING.md(意图 → 动效)和 docs/INTEGRATION.md(按技术栈划分)。
1. 选择(切勿凭记忆猜测)
node cli/mgl.mjs suggest "<用户描述的简要说明>"— 对 ★ 配方的和动效进行排序,说明理由,并打印一个 props 代码片段。支持过滤参数--overlay --image --text --loop --light --category <c> --json。node cli/mgl.mjs recipes— 即用型混合配方(预览图在recipes/previews/<id>.jpg):hero-aurora-night, hero-paper-sketch, hero-blueprint-logo, product-launch, stats-reveal, testimonial-chat, testimonial-quote, loading-loop, section-divider, success-celebration, error-glitch, onboarding-steps, event-countdown, music-neon-promo, ocean-explainer, history-timeline, app-store-preview (9:16), social-short-captions (9:16), end-card。node cli/mgl.mjs info <id>— 显示 props 以及roles、overlay/overlayProps、loopable、mood、weight、pairsWith、textProps等信息。- 混合规则:背景 + 主体 + 类型 + 微妙的强调;每个镜头只用一个主角;调暗支持图层;替换所有示例文本;传入品牌颜色。
2. 视频(Remotion)
node cli/mgl.mjs render <id> --props '{"key":"value"}' [--format landscape|square|portrait] [--frames N] --out out/<name>.mp4
node cli/mgl.mjs recipe <id> --overrides '{"<motion-id>":{…}}' [--format …] --out out/<name>.mp4
node cli/mgl.mjs still <id> --at 10,60,120 --out out/<name>-sheet.jpg # 先预览,再读取缩略图
node cli/mgl.mjs compose specs/<name>.json --out out/<name>.mp4 # scenes[] (motion 或 layers[]), transitions, overlays, audio
node cli/direct.mjs storyboards/<name>.json # 带解说:本地 Qwen3-TTS -> 字幕 -> 渲染 -> 主输出
图片:使用 public/ 路径(如 "demo/owl.jpg")或 https URL。切勿使用云端语音/音乐服务;音乐/音效来自 public/music、public/sfx。
如果需要在另一个 Remotion 项目中使用:node cli/mgl.mjs add <motions|recipes> --to <host>/src (仅复制所需源码和本地注册表;会打印 npm install 命令)。
3. 网站 / Web 应用
- 先在动效库中执行
npm run build:lib,然后在项目中import {MotionBackground, MotionPlayer, MotionMix} from 'opus-motion-library/web'(Vite 需要在resolve.dedupe中添加 react/remotion/@remotion/*/three),或者执行mgl add … --player --to <app>/src(Next.js 需从'use client'文件中使用)。 - 普通 HTML / WordPress / Vue / Svelte:使用
<script src="opus-motion.element.js">+<opus-motion recipe="…" background>/<opus-motion motion="…" props='{…}'>。 - 在
MotionBackground上使用 HTML 文字(它会丢弃type类型的图层);overlay动效悬浮在页面上;支持playOnView、减少动效的静态帧、懒加载、每个视口最多 2 个活动播放器;复杂 3D 动效在手机上使用导出的视频。 - 提供动效库
public/中使用的文件(或使用assetBase/ 绝对 URL)。
4. 原生应用、幻灯片、编辑器
node cli/mgl.mjs export <motion|recipe> --as mp4|webm|webm-alpha|prores-alpha|gif|png|poster [--format …] [--props …]
(Alpha 导出会应用 overlayProps;用 ffprobe -c:v libvpx-vp9 … pix_fmt 验证 → 应为 yuva420p)。
5. 交付前检查
生成缩略图图块(ffmpeg -i out/x.mp4 -vf "fps=1,scale=480:-2,tile=6x5" -frames:v 1 out/x-sheet.jpg)或截取页面截图(node examples/screenshot.mjs <url> <dir> --targets "top,#section" — 间隔 1 秒拍摄两张,报告变化百分比),查看结果并修复问题。
向动效库添加新动效
请遵循 docs/AUTHORING.md 的说明,将动效放入 src/motions/<family>/<id>.tsx,然后运行 node cli/gen-registry.mjs && npx tsc --noEmit && node cli/gen-docs.mjs;可选地运行 node cli/probe-meta.mjs --only <id>(测量 loop / overlay / luma 属性),并在 docs/motion-meta.json 中添加覆盖设置。