srt-remotion-video
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSRT Remotion Video - 主流程编排
SRT Remotion Video - Main Workflow Orchestration
将 SRT 字幕文件转换为 Remotion 视频的完整工作流。
Complete workflow for converting SRT subtitle files into Remotion videos.
工作流概览
Workflow Overview
text
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────────────┐ ┌──────────┐
│ 获取 SRT │ → │ 依赖预检 │ → │ 项目初始化│ → │ 生成分镜 │ → │ 并行 Creator 规划实现 │ → │ 合成视频 │
│ 文件路径 │ │ / 首次安装│ │ │ │ │ │ scene-plan + code │ │ │
└──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────────────────┘ └──────────┘text
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────────────┐ ┌──────────┐
│ Get SRT │ → │ Dependency │ → │ Project │ → │ Generate │ → │ Parallel Creator │ → │ Synthesize│
│ File Path│ │ Precheck/ │ │ Initialization │ │ Storyboard │ │ Planning & Implementation │ │ Video │
│ │ │ First-time │ │ │ │ │ │ scene-plan + code │ │ │
│ │ │ Installation │ │ │ │ │ │ │ │ │
└──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────────────────┘ └──────────┘项目目录结构
Project Directory Structure
text
<skillRoot>/
├── SKILL.md
├── template/
├── references/
│ ├── storyboard-parser.md
│ └── scene-component-creator.md
└── scripts/
├── ensure-template-deps.js
├── init-project.js
├── generate-storyboard.js
├── generate-creator-scenes.js
├── generate-scenes-registry.js
├── scene-registry-utils.js
├── validate-project.js
└── validate-scene-plan.js
<srtDir>/
├── your-file.srt
└── remotion-video-projects/
└── {yyyy-mm-dd-hh-mm-ss}/text
<skillRoot>/
├── SKILL.md
├── template/
├── references/
│ ├── storyboard-parser.md
│ └── scene-component-creator.md
└── scripts/
├── ensure-template-deps.js
├── init-project.js
├── generate-storyboard.js
├── generate-creator-scenes.js
├── generate-scenes-registry.js
├── scene-registry-utils.js
├── validate-project.js
└── validate-scene-plan.js
<srtDir>/
├── your-file.srt
└── remotion-video-projects/
└── {yyyy-mm-dd-hh-mm-ss}/Path Contract
Path Contract
主流程和所有 SubAgent 统一使用以下绝对路径约定:
- : 当前
skillRootskill 目录的绝对路径srt-remotion-video - :
templateRoot{skillRoot}/template - :
referencesRoot{skillRoot}/references - :
scriptsRoot{skillRoot}/scripts - : 用户提供的 SRT 文件绝对路径
srtPath - :
projectBaseDir{dirname(srtPath)}/remotion-video-projects - : 当前项目实例目录,格式为
projectRoot{projectBaseDir}/{projectName}/
强制要求:
- SubAgent prompt 中必须写入展开后的绝对路径,不要只传变量名
- 阶段协议文档只能从 读取
referencesRoot - 脚本只能从 执行
scriptsRoot - 所有运行态状态必须由主 Agent 显式传递
The main workflow and all SubAgents uniformly use the following absolute path conventions:
- : Absolute path of the current
skillRootskill directorysrt-remotion-video - :
templateRoot{skillRoot}/template - :
referencesRoot{skillRoot}/references - :
scriptsRoot{skillRoot}/scripts - : Absolute path of the SRT file provided by the user
srtPath - :
projectBaseDir{dirname(srtPath)}/remotion-video-projects - : Directory of the current project instance, formatted as
projectRoot{projectBaseDir}/{projectName}/
Mandatory Requirements:
- SubAgent prompts must include expanded absolute paths, do not pass only variable names
- Stage protocol documents can only be read from
referencesRoot - Scripts can only be executed from
scriptsRoot - All runtime states must be explicitly passed by the main Agent
执行流程
Execution Workflow
步骤 0: 获取 SRT 文件
Step 0: Obtain SRT File
- 询问用户 SRT 文件路径
- 如果用户给的是相对路径,主 Agent 必须先自行判断该文件是否存在
- 若存在,主 Agent 必须先解析为绝对路径,再将解析后的绝对路径作为
srtPath - 若不存在,必须明确反馈用户路径无效,并要求提供正确路径
- 后续所有步骤统一使用最终确认过的绝对路径
srtPath
- Ask the user for the SRT file path
- If the user provides a relative path, the main Agent must first check whether the file exists
- If it exists, the main Agent must resolve it to an absolute path, then use the resolved absolute path as
srtPath - If it does not exist, clearly inform the user that the path is invalid and request a correct path
- All subsequent steps uniformly use the final confirmed absolute path
srtPath
步骤 1: 依赖预检与项目初始化
Step 1: Dependency Precheck and Project Initialization
关键:模板始终从 skill 内部复制,所有工作在字幕目录下的独立项目目录进行。
Key: Templates are always copied from inside the skill, and all work is performed in an independent project directory under the subtitle directory.
1.0 依赖预检(首次使用时自动安装)
1.0 Dependency Precheck (Automatically Installed on First Use)
执行:
bash
node "{skillRoot}/scripts/ensure-template-deps.js" "{templateRoot}"脚本会:
- 检查 和
{templateRoot}/package.json{templateRoot}/package-lock.json - 检查模板关键依赖是否已安装
- 若未安装,则在 下执行一次
{templateRoot}npm install - 若已安装,则直接跳过安装
- 安装或校验失败时返回明确错误,并停止主流程
Execute:
bash
node "{skillRoot}/scripts/ensure-template-deps.js" "{templateRoot}"The script will:
- Check and
{templateRoot}/package.json{templateRoot}/package-lock.json - Check whether key template dependencies are installed
- If not installed, execute once under
npm install{templateRoot} - If already installed, skip installation directly
- Return a clear error and stop the main workflow if installation or verification fails
1.1 默认行为:创建新项目
1.1 Default Behavior: Create a New Project
执行:
bash
node "{skillRoot}/scripts/init-project.js" --srt-path "{srtPath}"脚本会:
- 确保 存在
{dirname(srtPath)}/remotion-video-projects/ - 创建新的项目目录
remotion-video-projects/{yyyy-mm-dd-hh-mm-ss}/ - 从 复制模板文件;若模板依赖已安装,则一并复制已安装依赖
{skillRoot}/template/ - 输出项目信息 JSON
Execute:
bash
node "{skillRoot}/scripts/init-project.js" --srt-path "{srtPath}"The script will:
- Ensure exists
{dirname(srtPath)}/remotion-video-projects/ - Create a new project directory
remotion-video-projects/{yyyy-mm-dd-hh-mm-ss}/ - Copy template files from ; if template dependencies are already installed, copy the installed dependencies together
{skillRoot}/template/ - Output project information JSON
1.2 用户指定项目路径(仅当用户明确指定时)
1.2 User-Specified Project Path (Only When Explicitly Specified by User)
如果用户明确指定了项目路径,则直接使用该路径作为 ,跳过默认目录推导。
projectRootIf the user explicitly specifies a project path, use that path directly as and skip the default directory derivation.
projectRoot1.3 记录关键路径
1.3 Record Key Paths
从脚本输出或用户指定路径获取:
projectRootskillRoottemplateRootreferencesRootscriptsRootsrtPath
后续所有步骤都使用这些绝对路径。
Obtain from script output or user-specified path:
projectRootskillRoottemplateRootreferencesRootscriptsRootsrtPath
All subsequent steps use these absolute paths.
步骤 2: 生成分镜脚本
Step 2: Generate Storyboard Script
必须使用 SubAgent 执行此步骤。
主 Agent 负责:
- 计算并展开绝对路径:
storyboardReference = {referencesRoot}/storyboard-parser.mdstoryboardScript = {scriptsRoot}/generate-storyboard.js
- 启动一个 SubAgent
- 在 prompt 中写入实际绝对路径值
SubAgent prompt 模板:
text
你正在执行 srt-remotion-video 工作流的“分镜生成阶段”。
首先读取以下参考协议并严格按其步骤执行:
- {storyboardReference}
输入参数:
- skillRoot: {skillRoot}
- projectRoot: {projectRoot}
- srtPath: {srtPath}
重要:
1. 所有路径都已展开为绝对路径,不要自行猜测
2. 需要执行的脚本位于 {storyboardScript}
3. 完成后必须按参考协议中的“完成后返回”契约,返回结构化结果主流程必须等待返回结果,并读取 验证结构正确。
storyboard.jsonThis step must be executed using a SubAgent.
The main Agent is responsible for:
- Calculate and expand absolute paths:
storyboardReference = {referencesRoot}/storyboard-parser.mdstoryboardScript = {scriptsRoot}/generate-storyboard.js
- Start a SubAgent
- Write the actual absolute path values in the prompt
SubAgent prompt template:
text
You are executing the "Storyboard Generation Phase" of the srt-remotion-video workflow.
First read the following reference protocol and strictly follow its steps:
- {storyboardReference}
Input parameters:
- skillRoot: {skillRoot}
- projectRoot: {projectRoot}
- srtPath: {srtPath}
Important:
1. All paths have been expanded to absolute paths, do not guess on your own
2. The script to execute is located at {storyboardScript}
3. After completion, you must return structured results in accordance with the "Return After Completion" contract in the reference protocolThe main workflow must wait for the returned results and read to verify that the structure is correct.
storyboard.json步骤 3: 使用 SubAgent 规划并实现场景组件
Step 3: Use SubAgent to Plan and Implement Scene Components
读取 ,获取所有场景数据。
storyboard.jsonRead to obtain all scene data.
storyboard.json3.0 前置准备:计算分组
3.0 Preparatory Step: Calculate Grouping
typescript
const SCENES_PER_CREATOR = 5;
const sceneCount = storyboard.scenes.length;
const creatorCount = Math.ceil(sceneCount / SCENES_PER_CREATOR);creatorIdtypescript
const creatorId = `creator-${String(index + 1).padStart(2, '0')}`;示例:
- 第 1 个 creator:
creator-01 - 第 2 个 creator:
creator-02 - 第 10 个 creator:
creator-10
主流程必须始终使用该格式,不要省略前导零,不要改成其他命名方式。
typescript
const SCENES_PER_CREATOR = 5;
const sceneCount = storyboard.scenes.length;
const creatorCount = Math.ceil(sceneCount / SCENES_PER_CREATOR);The generation rule is fixed as:
creatorIdtypescript
const creatorId = `creator-${String(index + 1).padStart(2, '0')}`;Example:
- 1st creator:
creator-01 - 2nd creator:
creator-02 - 10th creator:
creator-10
The main workflow must always use this format, do not omit leading zeros, do not change to other naming conventions.
3.1 规划 Creator 任务
3.1 Plan Creator Tasks
主流程负责调度:
- 为每个 creator 生成
scenesDataPath = {projectRoot}/scene-plans/{creatorId}.scenes.json - 为每个 creator 计算:
creatorIdplanPath = {projectRoot}/scene-plans/{creatorId}.jsonvalidateScript = {scriptsRoot}/validate-scene-plan.js
- 对每个 creator 执行:
bash
node "{scriptsRoot}/generate-creator-scenes.js" \
"{projectRoot}/storyboard.json" \
"{creatorId}" \
"{SCENES_PER_CREATOR}" \
"{scenesDataPath}"- 主 Agent 将 的绝对路径写入 SubAgent prompt
{scenesDataPath} - 并行启动全部 creator SubAgent
The main workflow is responsible for scheduling:
- Generate for each creator
scenesDataPath = {projectRoot}/scene-plans/{creatorId}.scenes.json - Calculate for each creator:
creatorIdplanPath = {projectRoot}/scene-plans/{creatorId}.jsonvalidateScript = {scriptsRoot}/validate-scene-plan.js
- Execute for each creator:
bash
node "{scriptsRoot}/generate-creator-scenes.js" \
"{projectRoot}/storyboard.json" \
"{creatorId}" \
"{SCENES_PER_CREATOR}" \
"{scenesDataPath}"- The main Agent writes the absolute path of into the SubAgent prompt
{scenesDataPath} - Start all creator SubAgents in parallel
3.2 并行启动所有 Scene Creator
3.2 Start All Scene Creators in Parallel
每个 Creator 的 SubAgent prompt 模板:
text
你正在执行 srt-remotion-video 工作流的“场景规划与实现阶段”。
首先读取以下参考协议并严格按其步骤执行:
- {referencesRoot}/scene-component-creator.md
输入参数:
- skillRoot: {skillRoot}
- projectRoot: {projectRoot}
- creatorId: {creatorId}
- planPath: {planPath}
- scenesDataPath: {scenesDataPath}
- validateScript: {validateScript}
重要:
1. 所有路径都已展开为绝对路径,不要自行猜测
2. 当前 creator 的场景事实源只允许来自 {scenesDataPath}
3. 规划阶段只使用 {scenesDataPath}、{projectRoot}/cartoon-ui-style-guide.css、{projectRoot}/cartoon-ui-style-guide-reference.md 和 {skillRoot}/../remotion-best-practices/SKILL.md
4. 先生成 scene-plan JSON,再执行校验,校验通过后再编写场景组件
5. `beatPlan` 默认一段字幕对应一个 beat;如果相邻 segments 明显属于同一句连续表达,可以合并
6. 合并仅允许发生在相邻 segments 之间,禁止跳跃式组合
7. `beatPlan` 只声明 `segments` 和 `action`;实际时间必须从 scenesData[].segments 的 `relativeStart / relativeDuration` 推导
8. 场景主节奏必须绑定 scenesData[].segments[].relativeStart / relativeDuration
9. 默认保留宿主背景,在透明根层上围绕画面中部或中上区域组织主视觉;不要重建整屏背景
10. 组件接口固定为 React.FC<{ segments: Segment[] }> 且使用默认导出
11. 只负责产出 {projectRoot}/src/scenes/SceneXXX.tsx;若文件不存在则创建,若已存在则仅修改自己负责的场景文件
12. 不要手改 {projectRoot}/src/compositions/Main.tsx 或 generated-scenes.ts
13. 完成后必须按参考协议中的“完成后返回”契约,返回结构化结果
14. `remotion-best-practices` 与当前 skill 同级,固定入口为 {skillRoot}/../remotion-best-practices/SKILL.mdSubAgent prompt template for each Creator:
text
You are executing the "Scene Planning and Implementation Phase" of the srt-remotion-video workflow.
First read the following reference protocol and strictly follow its steps:
- {referencesRoot}/scene-component-creator.md
Input parameters:
- skillRoot: {skillRoot}
- projectRoot: {projectRoot}
- creatorId: {creatorId}
- planPath: {planPath}
- scenesDataPath: {scenesDataPath}
- validateScript: {validateScript}
Important:
1. All paths have been expanded to absolute paths, do not guess on your own
2. The scene data source for the current creator is only allowed to come from {scenesDataPath}
3. During the planning phase, only use {scenesDataPath}, {projectRoot}/cartoon-ui-style-guide.css, {projectRoot}/cartoon-ui-style-guide-reference.md and {skillRoot}/../remotion-best-practices/SKILL.md
4. First generate the scene-plan JSON, then perform validation, and only write scene components after validation passes
5. By default, one subtitle segment corresponds to one beat in `beatPlan`; if adjacent segments clearly belong to the same continuous expression, they can be merged
6. Merging is only allowed between adjacent segments, skip merging is prohibited
7. `beatPlan` only declares `segments` and `action`; actual timing must be derived from `relativeStart / relativeDuration` of scenesData[].segments
8. The main scene rhythm must be bound to scenesData[].segments[].relativeStart / relativeDuration
9. By default, retain the host background, organize the main visual around the middle or upper-middle area of the screen on a transparent root layer; do not rebuild the full-screen background
10. The component interface is fixed as React.FC<{ segments: Segment[] }> and uses default export
11. Only responsible for producing {projectRoot}/src/scenes/SceneXXX.tsx; create the file if it does not exist, only modify the scene files you are responsible for if it already exists
12. Do not manually modify {projectRoot}/src/compositions/Main.tsx or generated-scenes.ts
13. After completion, you must return structured results in accordance with the "Return After Completion" contract in the reference protocol
14. `remotion-best-practices` is at the same level as the current skill, with a fixed entry at {skillRoot}/../remotion-best-practices/SKILL.md3.3 等待所有 Creator 完成
3.3 Wait for All Creators to Complete
确认所有目标场景组件文件均已生成。
仅用于任务完成反馈,不作为最终注册文件组装或总时长计算的真实来源。componentResults
Confirm that all target scene component files have been generated.
is only used for task completion feedback, not as the real source for final registry file assembly or total duration calculation.componentResults
步骤 4: 合成视频
Step 4: Synthesize Video
4.1 生成场景注册文件
4.1 Generate Scene Registry File
普通视频生成流程不得重写 。
{projectRoot}/src/compositions/Main.tsx模板默认输出规格:。
1920x1080 / 30fps- 的
generated-scenes.ts由totalDurationInFrames生成,不要手改generate-scenes-registry.js - 中的
Main.tsx必须使用msToFrames动态获取帧率,不能硬编码useVideoConfig().fps常量FPS
执行:
bash
node "{scriptsRoot}/generate-scenes-registry.js" \
"{projectRoot}" \
"{projectRoot}/storyboard.json"运行时契约固定:
- 每个 都通过默认导出暴露组件
SceneXXX.tsx - 负责保存
generated-scenes.ts、start、duration、segmentsComponent - 负责用
Main.tsx把分段数据传给场景组件<Component segments={scene.segments} />
The normal video generation workflow must not rewrite .
{projectRoot}/src/compositions/Main.tsxDefault template output specification: .
1920x1080 / 30fps- in
totalDurationInFramesis generated bygenerated-scenes.ts, do not modify manuallygenerate-scenes-registry.js - in
msToFramesmust dynamically obtain the frame rate usingMain.tsx, do not hardcode theuseVideoConfig().fpsconstantFPS
Execute:
bash
node "{scriptsRoot}/generate-scenes-registry.js" \
"{projectRoot}" \
"{projectRoot}/storyboard.json"Runtime contract is fixed:
- Each exposes the component via default export
SceneXXX.tsx - is responsible for storing
generated-scenes.ts,start,duration,segmentsComponent - is responsible for passing segment data to scene components using
Main.tsx<Component segments={scene.segments} />
4.2 Root.tsx 总时长同步
4.2 Root.tsx Total Duration Synchronization
Root.tsx要求:
- 必须保持从
Root.tsx读取generated-scenes.tstotalDurationInFrames - 不要在流程中重复手算或手填总帧数
Root.tsxRequirements:
- must keep reading
Root.tsxfromtotalDurationInFramesgenerated-scenes.ts - Do not manually recalculate or fill in the total frame count during the workflow
4.3 校验项目产物完整性
4.3 Verify Project Product Integrity
渲染前必须执行:
bash
node "{scriptsRoot}/validate-project.js" \
"{projectRoot}" \
"{projectRoot}/storyboard.json"校验失败时必须停止流程,不得继续渲染。
Must execute before rendering:
bash
node "{scriptsRoot}/validate-project.js" \
"{projectRoot}" \
"{projectRoot}/storyboard.json"If verification fails, the workflow must be stopped and rendering cannot continue.
4.4 执行渲染
4.4 Execute Rendering
bash
cd "{projectRoot}"
npx remotion render Main out/output.mp4bash
cd "{projectRoot}"
npx remotion render Main out/output.mp4步骤 5: 完成
Step 5: Completion
通知用户:
- 视频已生成
- 输出路径:
{projectRoot}/out/output.mp4 - 场景数量: N
- 视频时长: X 秒
Notify the user:
- The video has been generated
- Output path:
{projectRoot}/out/output.mp4 - Number of scenes: N
- Video duration: X seconds
调试模式与重新渲染
Debug Mode and Re-Rendering
当主视频生成流程(步骤 0–5)完成后,用户可以请求"调试模式"或"重新渲染"。
这两个操作都假定已存在且场景组件已生成完毕。projectRoot
After the main video generation workflow (Steps 0–5) is completed, the user can request "debug mode" or "re-rendering".
Both operations assume thatexists and scene components have been generated.projectRoot
调试模式
Debug Mode
当用户说"调试模式"、"预览模式"或类似表述,并要求添加音频时执行。
Execute when the user says "debug mode", "preview mode" or similar expressions, and requests to add audio.
TM.0 获取音频文件
TM.0 Obtain Audio File
- 如果用户已提供音频文件路径,验证文件存在并解析为绝对路径
audioPath - 如果用户未提供音频文件路径,必须向用户询问
- 验证文件存在,若不存在则反馈用户并停止
- If the user has provided an audio file path, verify that the file exists and resolve it to an absolute path
audioPath - If the user has not provided an audio file path, must ask the user for it
- Verify that the file exists; if not, inform the user and stop
TM.1 添加音频到时间轴
TM.1 Add Audio to Timeline
- 确保 目录存在
{projectRoot}/public/ - 将音频文件复制为
{projectRoot}/public/audio.mp3
bash
mkdir -p "{projectRoot}/public"
cp "{audioPath}" "{projectRoot}/public/audio.mp3"-
修改:
{projectRoot}/src/compositions/Main.tsx- 在 import 行添加 和
Audio:staticFiletypescriptimport { AbsoluteFill, Audio, Sequence, staticFile, useCurrentFrame } from "remotion"; - 在 的直接子级最前面添加:
<AbsoluteFill style={{ backgroundColor: ... }}>tsx<Audio src={staticFile("audio.mp3")} />
- 在 import 行添加
-
启动 Remotion Studio 供用户预览:
bash
cd "{projectRoot}"
npx remotion studio- Ensure the directory exists
{projectRoot}/public/ - Copy the audio file as
{projectRoot}/public/audio.mp3
bash
mkdir -p "{projectRoot}/public"
cp "{audioPath}" "{projectRoot}/public/audio.mp3"-
Modify:
{projectRoot}/src/compositions/Main.tsx- Add and
Audioto the import line:staticFiletypescriptimport { AbsoluteFill, Audio, Sequence, staticFile, useCurrentFrame } from "remotion"; - Add the following as the first direct child inside :
<AbsoluteFill style={{ backgroundColor: ... }}>tsx<Audio src={staticFile("audio.mp3")} />
- Add
-
Start Remotion Studio for user preview:
bash
cd "{projectRoot}"
npx remotion studioTM.2 完成通知
TM.2 Completion Notification
告知用户 Remotion Studio 已启动,音频已添加到时间轴,可在浏览器中预览。
Inform the user that Remotion Studio has been started, audio has been added to the timeline, and they can preview in the browser.
重新渲染
Re-Rendering
当用户说"重新渲染"、"再次渲染"或类似表述时执行。
Execute when the user says "re-render", "render again" or similar expressions.
RR.0 移除时间轴上的音频
RR.0 Remove Audio from Timeline
渲染最终视频前,必须确保 中不存在音频组件:
Main.tsx- 读取
{projectRoot}/src/compositions/Main.tsx - 检查是否包含 标签
<Audio - 如果存在:
- 移除 这一行
<Audio src={staticFile("audio.mp3")} /> - 从 import 语句中移除 和
Audio(如果它们不再被其他代码使用)staticFile
- 移除
- 如果不存在,跳过此步骤
Before rendering the final video, ensure that there is no audio component in :
Main.tsx- Read
{projectRoot}/src/compositions/Main.tsx - Check if it contains the tag
<Audio - If it exists:
- Remove the line
<Audio src={staticFile("audio.mp3")} /> - Remove and
Audiofrom the import statement (if they are no longer used by other code)staticFile
- Remove the line
- If it does not exist, skip this step
RR.1 执行渲染
RR.1 Execute Rendering
bash
cd "{projectRoot}"
npx remotion render Main out/output.mp4bash
cd "{projectRoot}"
npx remotion render Main out/output.mp4RR.2 完成通知
RR.2 Completion Notification
通知用户视频已重新渲染,输出路径为 。
{projectRoot}/out/output.mp4Notify the user that the video has been re-rendered, and the output path is .
{projectRoot}/out/output.mp4高分辨率 / 高帧率渲染
High Resolution / High Frame Rate Rendering
当主视频生成流程已经完成,用户要求生成 4K、60fps 或其他高于默认配置(1080p 30fps)的版本时执行。
这个操作假定已存在且场景组件已生成完毕。projectRoot
Execute when the main video generation workflow is completed and the user requests to generate a version with higher specifications than the default configuration (1080p 30fps), such as 4K, 60fps, etc.
This operation assumes thatexists and scene components have been generated.projectRoot
关键原则:设计分辨率与输出分辨率分离
Key Principle: Separate Design Resolution from Output Resolution
场景组件中的所有元素(卡片、图标、文字等)使用绝对像素值,基于 1920x1080 设计。直接将 Root.tsx 的 width/height 改为 3840x2160 会导致所有元素在画面中占比缩小。正确做法是保持设计分辨率 1920x1080 不变,通过 Remotion 的 参数放大输出分辨率。
--scaleAll elements in scene components (cards, icons, text, etc.) use absolute pixel values, designed based on 1920x1080. Directly changing the width/height of Root.tsx to 3840x2160 will cause all elements to shrink in proportion in the frame. The correct approach is to keep the design resolution at 1920x1080 unchanged, and scale the output resolution using Remotion's parameter.
--scale常见错误(禁止使用)
Common Mistakes (Prohibited)
| 错误做法 | 后果 |
|---|---|
| 改 Root.tsx 的 width=3840 height=2160 | 所有场景元素占比缩小一半 |
用 | 同上 |
| 只改 fps 不改 totalDurationInFrames | 视频只有前半段有内容,后半段空白 |
Main.tsx 中硬编码 | 改了 Root.tsx fps 后场景时序错乱 |
| Wrong Practice | Consequence |
|---|---|
| Change Root.tsx to width=3840 height=2160 | All scene elements shrink by half |
Use | Same as above |
| Only change fps without modifying totalDurationInFrames | Only the first half of the video has content, the second half is blank |
Hardcode | Scene timing is messed up after changing Root.tsx fps |
HR.0 确认用户需求
HR.0 Confirm User Requirements
解析用户需求为具体的输出参数:
| 用户需求 | Root.tsx 修改 | generated-scenes.ts 修改 | 渲染命令 |
|---|---|---|---|
| 4K / 超清 | 不改 | 不改 | |
| 60fps | | | 无需 scale |
| 4K 60fps | | | |
Parse user requirements into specific output parameters:
| User Requirement | Root.tsx Modification | generated-scenes.ts Modification | Render Command |
|---|---|---|---|
| 4K / Ultra HD | No change | No change | |
| 60fps | | Convert | No scale needed |
| 4K 60fps | | Convert | |
HR.1 修改帧率(仅当用户要求高帧率时)
HR.1 Modify Frame Rate (Only When User Requests High Frame Rate)
- 修改 中的
{projectRoot}/src/Root.tsx值:fps
typescript
fps={60} // 从 30 改为 60- 修改 中的
{projectRoot}/src/compositions/generated-scenes.ts:totalDurationInFrames
typescript
// 帧数 = 原帧数 × (新fps / 原fps)
// 例如 30→60fps: 1572 × 2 = 3144
export const totalDurationInFrames = {原帧数 × 新fps / 原fps};关键: 中 的 和 不要修改,必须保持 和 。分辨率放大由渲染时的 参数完成,而非修改设计分辨率。
{projectRoot}/src/Root.tsx<Composition>widthheight19201080--scale中的Main.tsx必须使用msToFrames动态获取帧率。如果发现useVideoConfig().fps中有硬编码的Main.tsx常量,必须先修复为FPS,否则 fps 变更后场景时序会完全错乱。useVideoConfig().fps
- Modify the value in
fps:{projectRoot}/src/Root.tsx
typescript
fps={60} // Changed from 30 to 60- Modify in
totalDurationInFrames:{projectRoot}/src/compositions/generated-scenes.ts
typescript
// Frame count = original frame count × (new fps / original fps)
// Example: 30→60fps: 1572 × 2 = 3144
export const totalDurationInFrames = {original frame count × new fps / original fps};Key: The and of in must not be modified, and must remain and . Resolution scaling is done by the parameter during rendering, not by modifying the design resolution.
widthheight<Composition>{projectRoot}/src/Root.tsx19201080--scaleinmsToFramesmust dynamically obtain the frame rate usingMain.tsx. If a hardcodeduseVideoConfig().fpsconstant is found inFPS, it must be fixed toMain.tsxfirst, otherwise scene timing will be completely messed up after fps changes.useVideoConfig().fps
HR.2 校验项目
HR.2 Verify Project
bash
node "{scriptsRoot}/validate-project.js" \
"{projectRoot}" \
"{projectRoot}/storyboard.json"校验失败时必须停止,不得继续渲染。
bash
node "{scriptsRoot}/validate-project.js" \
"{projectRoot}" \
"{projectRoot}/storyboard.json"If verification fails, must stop and cannot continue rendering.
HR.3 执行渲染
HR.3 Execute Rendering
bash
cd "{projectRoot}"
npx remotion render Main out/output-4k.mp4 --scale 2- :将 1920x1080 的设计画布放大 2 倍渲染为 3840x2160
--scale 2 - 矢量元素(文字、SVG)会以更高分辨率渲染,画质更清晰
- 画面布局与 1080p 完全一致,不存在元素缩小的问题
- 如果不需要 4K 只需 60fps,去掉 即可
--scale 2
bash
cd "{projectRoot}"
npx remotion render Main out/output-4k.mp4 --scale 2- : Scale the 1920x1080 design canvas by 2x to render as 3840x2160
--scale 2 - Vector elements (text, SVG) will be rendered at higher resolution, resulting in clearer image quality
- The layout is exactly the same as 1080p, no element shrinking issue
- If only 60fps is needed without 4K, remove
--scale 2
HR.4 完成通知
HR.4 Completion Notification
通知用户:
- 输出路径:
{projectRoot}/out/output-4k.mp4 - 输出分辨率、帧率、时长
- 如有 fps 修改,提醒用户 Root.tsx 中的 fps 已从 30 改为目标值
Notify the user:
- Output path:
{projectRoot}/out/output-4k.mp4 - Output resolution, frame rate, duration
- If fps was modified, remind the user that the fps in Root.tsx has been changed from 30 to the target value
数据结构参考
Data Structure Reference
storyboard.json
storyboard.json
typescript
interface Storyboard {
totalDuration: number;
sceneCount: number;
scenes: {
id: string;
startTime: number;
duration: number;
segments: {
text: string;
relativeStart: number;
relativeDuration: number;
}[];
semanticTags?: string[];
visualHint?: string;
}[];
}typescript
interface Storyboard {
totalDuration: number;
sceneCount: number;
scenes: {
id: string;
startTime: number;
duration: number;
segments: {
text: string;
relativeStart: number;
relativeDuration: number;
}[];
semanticTags?: string[];
visualHint?: string;
}[];
}scene-plan JSON
scene-plan JSON
typescript
interface ScenePlanCard {
sceneId: string;
goal: string;
layout: string;
visualCore: string;
surface: string;
emphasis: string;
screenShouldShow: string[];
beatPlan: {
segments: number[];
action: string;
}[];
}typescript
interface ScenePlanCard {
sceneId: string;
goal: string;
layout: string;
visualCore: string;
surface: string;
emphasis: string;
screenShouldShow: string[];
beatPlan: {
segments: number[];
action: string;
}[];
}SceneComponentResult
SceneComponentResult
typescript
interface SceneComponentResult {
sceneId: string;
componentPath: string;
componentName?: string;
planPath?: string;
}typescript
interface SceneComponentResult {
sceneId: string;
componentPath: string;
componentName?: string;
planPath?: string;
}Resources
Resources
template/
template/
- 轻量模板项目,随 skill 一起分发
- 首次使用时在模板目录执行依赖安装,后续项目复用模板依赖
- Lightweight template project, distributed with the skill
- Dependencies are installed in the template directory on first use, and subsequent projects reuse template dependencies
references/
references/
- :分镜生成阶段协议
storyboard-parser.md - :场景规划与实现阶段协议
scene-component-creator.md - :主题模板更换指南
theme-template-switching.md
- : Storyboard generation phase protocol
storyboard-parser.md - : Scene planning and implementation phase protocol
scene-component-creator.md - : Theme template switching guide
theme-template-switching.md
scripts/
scripts/
- :检查模板依赖,必要时执行首次安装
ensure-template-deps.js - :根据
init-project.js初始化项目srtPath - :根据 SRT 和 groups.json 生成 storyboard.json
generate-storyboard.js - :根据 storyboard.json 为指定 creator 生成 scenesData JSON
generate-creator-scenes.js - :生成
generate-scenes-registry.jsgenerated-scenes.ts - :registry 和校验共用工具
scene-registry-utils.js - :渲染前完整性校验
validate-project.js - :校验 scene-plan JSON 结构与 segment 绑定
validate-scene-plan.js
- : Check template dependencies, perform first-time installation if necessary
ensure-template-deps.js - : Initialize project based on
init-project.jssrtPath - : Generate storyboard.json based on SRT and groups.json
generate-storyboard.js - : Generate scenesData JSON for the specified creator based on storyboard.json
generate-creator-scenes.js - : Generate
generate-scenes-registry.jsgenerated-scenes.ts - : Shared utilities for registry and validation
scene-registry-utils.js - : Integrity check before rendering
validate-project.js - : Validate scene-plan JSON structure and segment binding
validate-scene-plan.js
执行清单
Execution Checklist
主流程
Main Workflow
- 获取用户提供的 SRT 绝对路径
- 运行 检查模板依赖,必要时完成首次安装
ensure-template-deps.js - 运行 创建项目
init-project.js --srt-path - 获取 、
projectRoot、skillRoot、templateRoot、referencesRootscriptsRoot - 使用 生成
references/storyboard-parser.mdstoryboard.json - 验证 结构正确
storyboard.json - 计算 Creator 分组
- 使用 并行生成 scene-plan 与场景组件
references/scene-component-creator.md - 运行
generate-scenes-registry.js - 运行
validate-project.js - 执行渲染
- Obtain the absolute path of the SRT file provided by the user
- Run to check template dependencies, complete first-time installation if necessary
ensure-template-deps.js - Run to create project
init-project.js --srt-path - Obtain ,
projectRoot,skillRoot,templateRoot,referencesRootscriptsRoot - Generate using
storyboard.jsonreferences/storyboard-parser.md - Verify that structure is correct
storyboard.json - Calculate Creator grouping
- Generate scene-plan and scene components in parallel using
references/scene-component-creator.md - Run
generate-scenes-registry.js - Run
validate-project.js - Execute rendering
调试模式
Debug Mode
- 获取用户提供的音频文件绝对路径
- 复制音频到
{projectRoot}/public/audio.mp3 - 修改 添加
Main.tsx组件<Audio> - 启动 Remotion Studio 供用户预览
- Obtain the absolute path of the audio file provided by the user
- Copy audio to
{projectRoot}/public/audio.mp3 - Modify to add
Main.tsxcomponent<Audio> - Start Remotion Studio for user preview
重新渲染
Re-Rendering
- 检查 是否存在
Main.tsx标签<Audio> - 若存在则移除 及相关 import
<Audio> - 执行渲染
- Check if contains
Main.tsxtag<Audio> - If exists, remove and related imports
<Audio> - Execute rendering
高分辨率 / 高帧率渲染
High Resolution / High Frame Rate Rendering
- 解析用户需求为具体的输出分辨率、帧率和 scale 值
- 确认 中
Main.tsx使用msToFrames而非硬编码常量useVideoConfig().fps - 仅当需要高帧率时:修改 的
Root.tsx和fps的generated-scenes.tstotalDurationInFrames - 确认 的
Root.tsx/width保持 1920/1080 不变height - 运行 校验
validate-project.js - 使用 (4K时)执行渲染
--scale 2
- Parse user requirements into specific output resolution, frame rate and scale values
- Confirm that in
msToFramesusesMain.tsxinstead of hardcoded constantsuseVideoConfig().fps - Only when high frame rate is required: modify in
fpsandRoot.tsxintotalDurationInFramesgenerated-scenes.ts - Confirm that /
widthinheightremain 1920/1080 unchangedRoot.tsx - Run for verification
validate-project.js - Execute rendering with (for 4K)
--scale 2
注意事项
Notes
- 所有路径必须使用绝对路径
- SubAgent prompt 中必须传入实际路径值,不能只传变量名
- 模板资源位于
{skillRoot}/template - 模板以轻量形式分发,首次使用时必须先完成 依赖预检
template/ - 默认项目目录位于
{dirname(srtPath)}/remotion-video-projects - 、
Main.tsx属于受保护宿主层Root.tsx - 场景组件必须真实消费
segments - 失败时不得继续渲染
validate-project.js - 如果用户想更换主题模板,必须先参考
references/theme-template-switching.md
- All paths must use absolute paths
- SubAgent prompts must pass actual path values, not just variable names
- Template resources are located at
{skillRoot}/template - Templates are distributed in lightweight form, dependency precheck in must be completed on first use
template/ - Default project directory is located at
{dirname(srtPath)}/remotion-video-projects - and
Main.tsxbelong to the protected host layerRoot.tsx - Scene components must actually consume
segments - Rendering cannot continue if fails
validate-project.js - If the user wants to change the theme template, must first refer to
references/theme-template-switching.md