Install
openclaw skills install srt-to-videoConvert SRT subtitle files into Remotion typing-animation videos with character-by-character text reveal and cinematic animated backgrounds. Use when the user wants a typewriter subtitle effect, SRT-to-video conversion, animated captions, or a Remotion project generated from subtitle files.
openclaw skills install srt-to-video将 .srt 字幕文件一键转化为 Remotion (React) 视频项目,生成带有"逐字打字机"特效 + 科幻星空背景的精美视频。
用户提供:
.srt 字幕文件(标准 SRT 格式)1920x1080(横版,默认) 或 1080x1920(竖版/短视频)starfield(默认星空) / gradient(纯渐变) / custom(用户自定义)slow(8帧/字) / normal(5帧/字,默认) / fast(3帧/字)将 SRT 文件解析为时间轴数据结构:
interface SubtitleSegment {
index: number;
startTime: number; // in seconds
endTime: number; // in seconds
text: string;
}
SRT 格式示例:
1
00:00:01,000 --> 00:00:04,000
人是怎样变强的?
2
00:00:04,500 --> 00:00:06,500
答:表演
解析规则:
HH:MM:SS,mmm --> HH:MM:SS,mmm根据解析结果生成帧级时间轴:
// 将 SRT 时间转化为帧号
function timeToFrame(timeStr: string, fps: number): number {
const [hours, minutes, rest] = timeStr.split(':');
const [seconds, ms] = rest.split(',');
const totalSeconds = parseInt(hours) * 3600 + parseInt(minutes) * 60 +
parseInt(seconds) + parseInt(ms) / 1000;
return Math.round(totalSeconds * fps);
}
为每段字幕计算:
startFrame:字幕开始帧(从 SRT 时间码)endFrame:字幕结束帧(从 SRT 时间码)typingSpeed:按文本长度和持续时间自动计算(确保在持续时间的 60-70% 内打完字,剩余时间保持显示)fontSize:根据文本长度自动调节(短文本大号,长文本小号)color:自动分配颜色方案自动 fontSize 计算规则:
20 字: 42px
自动颜色循环:
const COLOR_PALETTE = [
'#FFFFFF', // 白色 — 叙述
'#FFD866', // 金色 — 强调/结论
'#87CEEB', // 天蓝 — 解释/分析
'#DDA0DD', // 紫色 — 情感/转折
'#C8C8D0', // 灰白 — 过渡/补充
];
在用户指定目录(或默认 scratch 目录)下创建完整的 Remotion 项目:
<project-name>/
├── src/
│ ├── components/
│ │ ├── TypingText.tsx ← 逐字打字组件
│ │ └── Background.tsx ← 动态星空背景
│ ├── Composition.tsx ← 主合成:时间轴 + 字幕渲染
│ └── index.tsx ← Root 注册
├── package.json
└── tsconfig.json
项目创建后,按以下流程操作:
# 1. 安装依赖
cd <project-name> && npm install
# 2. 预览(Remotion Studio)
npm start
# 浏览器打开 http://localhost:3000 预览效果
# 3. 渲染最终视频
npm run build
# 输出到 out/video.mp4
逐字符显示文本,每个字符出现时带轻微缩放弹入效果:
localFrame / typingSpeed 决定已显示字符数scale(1.15) → scale(1), opacity: 0.5 → 1Math.sin(frame * 0.15) > 0)0 0 30px rgba(100, 200, 255, 0.3) 营造发光感letterSpacing: '0.05em'动态科幻星空背景,纯 useCurrentFrame() 驱动:
skewX 变形radial-gradient 压暗四角fadeIn(8 帧渐入)和 fadeOut(15 帧渐出)useCurrentFrame() + interpolate() / spring() 驱动(Remotion 核心规则)npm install && npm start 即可预览输入 SRT:
1
00:00:01,000 --> 00:00:04,000
人是怎样变强的?
2
00:00:04,500 --> 00:00:07,000
答:表演
3
00:00:08,000 --> 00:00:12,000
心理学上叫神经可塑性
输出:一个完整的 Remotion 项目,3 段字幕按时间轴依次以打字效果展示,配合星空背景动画。