srt-to-video

Convert 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.

Safety Notice

This item is sourced from the public archived skills repository. Treat as untrusted until reviewed.

Copy this and send it to your AI assistant to learn

Install skill "srt-to-video" with this command: npx skills add 0x00000003/srt-to-video

SRT → 打字动画视频 Skill

.srt 字幕文件一键转化为 Remotion (React) 视频项目,生成带有"逐字打字机"特效 + 科幻星空背景的精美视频。


输入

用户提供:

  1. 一个 .srt 字幕文件(标准 SRT 格式)
  2. 可选参数
    • 画幅:1920x1080(横版,默认) 或 1080x1920(竖版/短视频)
    • 背景风格:starfield(默认星空) / gradient(纯渐变) / custom(用户自定义)
    • 打字速度:slow(8帧/字) / normal(5帧/字,默认) / fast(3帧/字)
    • 字体颜色方案:默认自动分配(白色/金色/蓝色/紫色交替)

工作流程

Step 1: 解析 SRT 文件

将 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
  • 第三行起是字幕文本(可多行)
  • 时间码用于确定每段字幕的开始帧和结束帧

Step 2: 生成时间轴

根据解析结果生成帧级时间轴:

// 将 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 计算规则:

  • ≤ 5 字: 88px
  • 6-10 字: 72px
  • 11-15 字: 56px
  • 16-20 字: 48px
  • 20 字: 42px

自动颜色循环:

const COLOR_PALETTE = [
  '#FFFFFF',   // 白色 — 叙述
  '#FFD866',   // 金色 — 强调/结论
  '#87CEEB',   // 天蓝 — 解释/分析
  '#DDA0DD',   // 紫色 — 情感/转折
  '#C8C8D0',   // 灰白 — 过渡/补充
];

Step 3: 创建 Remotion 项目

在用户指定目录(或默认 scratch 目录)下创建完整的 Remotion 项目:

<project-name>/
├── src/
│   ├── components/
│   │   ├── TypingText.tsx      ← 逐字打字组件
│   │   └── Background.tsx      ← 动态星空背景
│   ├── Composition.tsx          ← 主合成:时间轴 + 字幕渲染
│   └── index.tsx                ← Root 注册
├── package.json
└── tsconfig.json

Step 4: 渲染

项目创建后,按以下流程操作:

# 1. 安装依赖
cd <project-name> && npm install

# 2. 预览(Remotion Studio)
npm start
# 浏览器打开 http://localhost:3000 预览效果

# 3. 渲染最终视频
npm run build
# 输出到 out/video.mp4

核心组件规范

TypingText 组件

逐字符显示文本,每个字符出现时带轻微缩放弹入效果:

  • 打字效果localFrame / typingSpeed 决定已显示字符数
  • 字符动画:每个新出现的字符从 scale(1.15)scale(1), opacity: 0.51
  • 光标:打字时常亮,完成后闪烁(Math.sin(frame * 0.15) > 0
  • 文字阴影0 0 30px rgba(100, 200, 255, 0.3) 营造发光感
  • 字间距letterSpacing: '0.05em'

Background 组件

动态科幻星空背景,纯 useCurrentFrame() 驱动:

  • 渐变底色:三色渐变(深蓝→深紫→暗灰),色相随帧缓慢偏移
  • 星星:40 个随机分布的点,亮度按帧做正弦闪烁
  • 流星:5 条周期性流星,带角度和拖尾
  • 星云光晕:2 个模糊的椭圆径向渐变,缓慢漫游
  • 极光丝带:模糊的椭圆形色带,带 skewX 变形
  • 暗角radial-gradient 压暗四角

Composition 主合成

  • 每次屏幕上只显示 一行字幕
  • 每段字幕有 fadeIn(8 帧渐入)和 fadeOut(15 帧渐出)
  • 只在当前帧 ± 范围内渲染对应字幕,避免性能浪费
  • 总时长根据 SRT 最后一条字幕的 endTime 自动计算

硬规则

  1. 禁止 CSS transition/animation,所有动画必须用 useCurrentFrame() + interpolate() / spring() 驱动(Remotion 核心规则)
  2. SRT 时间码优先,严格按照 SRT 文件的时间码定位每段字幕,不自行重算除非用户明确要求
  3. 一屏一句,屏幕上同时只显示一条字幕
  4. 自动适配,fontSize、color、typingSpeed 全部自动计算,用户无需手动指定
  5. 项目可独立运行,生成的项目 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 段字幕按时间轴依次以打字效果展示,配合星空背景动画。

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

A2a Match

# A2A Match - 智能供需匹配平台

Archived SourceRecently Updated
General

image-downloader

当用户需要按关键词批量下载图片、从 Bing 或多个图片来源收集候选、保存图片到本地目录、避免重复下载,或希望复用当前仓库里的现成图片下载流程时使用。遇到类似“帮我按关键词下载 10 张图片”“批量抓取 Bing 图片并保存到本地”“从多个来源收集图片候选再下载”“需要下载摘要和保存目录”这类请求时,应主动使用这个 skill。

Archived SourceRecently Updated
General

article_link

文章链接提取工具。提交付费媒体文章链接,自动匹配已有内容并返回英文全文,或排队提取。支持 Barron's、Bloomberg、Financial Times、Foreign Policy、Handelsblatt、MarketWatch、New York Times、Reuters、The Atlantic、The Economist、The New Yorker、Wall Street Journal、Washington Post、Wired 共 15 家媒体。需要 Import Token 鉴权,每日有次数限制。Article link extraction tool. Supports Barron's, Bloomberg, FT, Foreign Policy, Handelsblatt, MarketWatch, NYT, Reuters, The Atlantic, The Economist, The New Yorker, WSJ, Washington Post, Wired (15 outlets). Requires Import Token.

Archived SourceRecently Updated
General

xiaoyi-claw-omega-final

六层架构智能助手文档 - 包含架构设计、身份定义、工具规则等纯文档内容。无代码执行,无外部连接,无凭据要求。

Archived SourceRecently Updated