用途
该技能专门用于将已有的 Remotion(React)合成源码迁移至 HyperFrames(HTML + GSAP)合成。只有当用户明确要求迁移、转换或翻译 Remotion 源码时才应使用。典型触发短语包括:"port my Remotion project to HyperFrames"、"convert this Remotion code to HyperFrames"、"migrate from Remotion"、"translate this Remotion comp"、"rewrite this as HyperFrames HTML"。
若用户是在编写新的 HyperFrames 合成(即使受到某个 Remotion 视频启发)、仅顺带提及 Remotion、将 Remotion 代码作为参考资料而非要求翻译,或要求"与我的 Remotion 视频相同"但未明确要求迁移源码,则不应使用该技能。
主要能力
该技能将 Remotion 的常见惯用法翻译为 HyperFrames 等价实现。据其说明,约 80% 的典型合成可机械式翻译,并通过拒绝不适合 HyperFrames seek 驱动模型的模式来防范有损的 20%。技能包含 Remotion API 与 HF 等价的映射索引(api-map.md),并按主题提供参考文档:
parameters.md:Composition、defaultProps、schema、calculateMetadatasequencing.md:Sequence、Series、Loop、AbsoluteFill、Freezetiming.md:useCurrentFrame、interpolate、spring、Easing、interpolateColorsmedia.md:Audio、Video、Img、IFrame、staticFile、delayRendertransitions.md:TransitionSeries、@remotion/transitionslottie.md:@remotion/lottiefonts.md:@remotion/google-fonts/<Family>、Font.loadFont、@font-face
工作流
- 检查源码:运行
scripts/lint_source.py检查 Remotion 源码目录。阻断项(如 useState、useReducer、带非空依赖的 useEffect/useLayoutEffect、异步 calculateMetadata、第三方 React UI 库)会导致停止并建议互操作模式;警告项(如 @remotion/lambda 配置、delayRender、useCallback、useMemo、自定义 hooks)在丢弃该构造后继续翻译;提示项(如 staticFile、interpolateColors)在带注释情况下翻译。 - 规划翻译:阅读
references/api-map.md,根据源码所用内容加载对应的主题参考文档。 - 生成 HF 合成:输出
index.html,包含根<div id="stage">(携带 data-composition-id、data-start、data-duration、data-fps、data-width、data-height 及各标量 prop 的 data-* 属性)、扁平化的场景 div 列表(带 data-start / data-duration / data-track-index)、内联<style>、底部一个暂停的gsap.timeline({ paused: true }),并通过window.__timelines["<composition-id>"] = tl;注册时间线。 - 验证:运行评估工具,渲染 Remotion 基线与 HF 翻译,进行 SSIM 差异比较。阈值约为源码复杂度层级 p05 以下 0.02。注意两次渲染必须使用匹配的像素格式,需在 Remotion 源码的
remotion.config.ts中设置Config.setVideoImageFormat("png")和Config.setColorSpace("bt709")。 - 记录缺口:对于未干净翻译的内容,在 HF 输出旁写入
TRANSLATION_NOTES.md。
适用场景
- 用户明确要求将现有 Remotion 项目迁移、转换或翻译为 HyperFrames。
- 需要评估翻译质量并验证 SSIM 阈值的场景。
限制
技能明确不支持以下场景:
- 反向方向:将 HyperFrames 合成导出回 Remotion 或任何其他框架不在支持范围内,翻译仅为 Remotion → HyperFrames 单向。
- 非 Remotion 来源:After Effects 项目(.aep)、Framer Motion / 纯 React / CSS 动画或其他工具源码不包含可翻译的 Remotion 源码,应通过
/general-video重新创建,或在 HyperFrames 无法表示时拒绝。 - React 状态机:通过 useState + useEffect 驱动动画的合成在 HyperFrames 的 seek 驱动模型中不是确定性帧捕获目标,建议使用运行时互操作模式(PR #214)。
- 与 HyperFrames 渲染管线并行运行 Remotion:这是 PR #214 中的运行时互操作模式,属于针对未通过 lint 的合成的独立解决方案。
当不确定时,默认使用 /general-video(通用 HyperFrames 编写流程)编写原生 HyperFrames 合成。
自评与基线
技能提供测试语料库编排器 ./assets/test-corpus/run.sh,运行 T1、T2、T3(渲染 + 差异)和 T4(lint 验证),打印各层级通过/失败表并生成聚合 JSON 报告。截至 2026-04-27 的已验证基线:T1(单元素淡入)平均 SSIM 0.974,阈值 0.95;T2(多场景 + spring + 音频 + 图像)平均 SSIM 0.985,阈值 0.95;T3(数据驱动、自定义子组件、计数)平均 SSIM 0.953,阈值 0.90;T4(escape-hatch,8 个 lint 用例)8/8 通过。