Communitygithub.com

Remotion 字幕——视频动画字幕

为 Remotion 视频添加动画字幕和说明文字,支持 .SRT 文件。实现 TikTok 风格逐词高亮、卡拉 OK 效果等。

Remotion 字幕——视频动画字幕 是什么?

这是一个为 Remotion 视频添加动画字幕的 AI agent 技能,能够从 .SRT 文件导入字幕,并支持多种动画效果,包括逐词高亮(类似 TikTok 风格)和卡拉 OK 效果。它基于 TypeScript/React 构建,需配合 Remotion 项目使用,安装简单,只需 `npm install remotion-subtitles`。该技能的核心是通过 `useSubtitles` 钩子加载 SRT 文件,然后使用 `SubtitleSequence` 组件渲染字幕,同时提供丰富的自定义样式选项和手动字幕控制。对于需要为视频添加专业、动态字幕的开发者来说,此技能非常有用,可以显著提升视频的观赏性和可访问性。它支持在底边居中显示字幕,并建议使用高对比度颜色、大字体和淡入动画以确保清晰度。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ever-just/agentskills/tree/HEAD/skills/remotion-captions

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Remotion 字幕——视频动画字幕 是做什么的?

为 Remotion 视频添加动画字幕和说明文字,支持 .SRT 文件。TikTok 风格逐词高亮、卡拉 OK 效果等。

概述

  • 仓库:github.com/ahgsql/remotion-subtitles
  • 语言:TypeScript / React
  • 许可证:开源
  • 安装:npm install remotion-subtitles
  • 依赖:Remotion 项目

设置

npm install remotion-subtitles

基本用法

从 SRT 文件加载

import { useSubtitles, SubtitleSequence } from "remotion-subtitles";

export const CaptionedVideo: React.FC = () => {
  const subtitles = useSubtitles("./subtitles.srt");

  return (
    <AbsoluteFill>
      <Video src={staticFile("video.mp4")} />
      <SubtitleSequence subtitles={subtitles} />
    </AbsoluteFill>
  );
};

SRT 格式

1
00:00:00,000 --> 00:00:02,500
欢迎使用自定义助手

2
00:00:02,500 --> 00:00:05,000
AI 驱动的电子邮件平台

3
00:00:05,000 --> 00:00:08,000
自动处理您的收件箱

字幕样式

<SubtitleSequence
  subtitles={subtitles}
  style={{
    position: "absolute",
    bottom: 80,
    left: 0,
    right: 0,
    textAlign: "center",
    fontSize: 42,
    fontWeight: "bold",
    color: "white",
    textShadow: "2px 2px 8px rgba(0,0,0,0.8)",
    fontFamily: "Inter, sans-serif",
  }}
/>

逐词高亮(TikTok 风格)

import { useCurrentFrame, interpolate } from "remotion";

export const WordHighlightCaption: React.FC<{
  words: { text: string; startFrame: number; endFrame: number }[];
}> = ({ words }) => {
  const frame = useCurrentFrame();

  return (
    <div style={{
      position: "absolute",
      bottom: 100,
      width: "100%",
      textAlign: "center",
      display: "flex",
      justifyContent: "center",
      gap: 8,
      flexWrap: "wrap",
      padding: "0 60px",
    }}>
      {words.map((word, i) => {
        const isActive = frame >= word.startFrame && frame <= word.endFrame;
        const scale = isActive
          ? interpolate(frame, [word.startFrame, word.startFrame + 3], [1, 1.15], { extrapolateRight: "clamp" })
          : 1;

        return (
          <span
            key={i}
            style={{
              fontSize: 48,
              fontWeight: 800,
              color: isActive ? "#FFD700" : "white",
              textShadow: isActive
                ? "0 0 20px rgba(255,215,0,0.5)"
                : "2px 2px 4px rgba(0,0,0,0.8)",
              transform: `scale(${scale})`,
              transition: "color 0.1s",
              display: "inline-block",
            }}
          >
            {word.text}
          </span>
        );
      })}
    </div>
  );
};

手动字幕计时

如果没有 SRT 文件,可以手动定义字幕:

const captions = [
  { text: "欢迎使用自定义助手", startFrame: 0, endFrame: 75 },
  { text: "AI 驱动的电子邮件自动化", startFrame: 80, endFrame: 150 },
  { text: "几分钟内创建助手", startFrame: 155, endFrame: 240 },
];

export const ManualCaptions: React.FC = () => {
  const frame = useCurrentFrame();

  const current = captions.find(
    (c) => frame >= c.startFrame && frame <= c.endFrame
  );

  if (!current) return null;

  const progress = interpolate(
    frame,
    [current.startFrame, current.startFrame + 10],
    [0, 1],
    { extrapolateRight: "clamp" }
  );

  return (
    <div style={{
      position: "absolute",
      bottom: 80,
      width: "100%",
      textAlign: "center",
      opacity: progress,
      transform: `translateY(${(1 - progress) * 10}px)`,
    }}>
      <span style={{
        fontSize: 44,
        fontWeight: 700,
        color: "white",
        backgroundColor: "rgba(0,0,0,0.6)",
        padding: "8px 24px",
        borderRadius: 8,
      }}>
        {current.text}
      </span>
    </div>
  );
};

最佳实践

  1. 放置在底部——标准字幕位置是底部居中
  2. 使用对比色——白色文字搭配深色阴影或半透明背景
  3. 大字体——40-50px 为最低限度,保证视频可读性
  4. 短句——最多两行,每个字幕 6-8 个词
  5. 时间缓冲——字幕比音频提前 2-3 帧开始
  6. 入场动画——轻微淡入/滑入,退出无动画
  7. 粗体——700+ 字重,确保视频可读性

来源

  • remotion-subtitles:github.com/ahgsql/remotion-subtitles
  • Remotion Audiogram 模板:github.com/remotion-dev/template-audiogram

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

ever-just/agentskills

> Declarative animations for React. Springs, gestures, layout animations, and page transitions. GPU-accelerated, production-ready.

ever-just/agentskills

> Create animated logos, icons, and micro-interactions as lightweight Lottie JSON files. No After Effects needed — build animations entirely in code.

ever-just/agentskills

> A TypeScript library using generators to program animations with a real-time editor. Ideal for explainer videos, code walkthroughs, and educational content.

ever-just/agentskills

> Create videos programmatically using React components. The most mature framework for code-driven video production.

ever-just/agentskills

> Copy-paste video components for Remotion. Intros, text effects, transitions, and full scene templates. Like shadcn/ui but for video.

ever-just/agentskills

Extract actionable intelligence from video content across YouTube, Vimeo, and company websites. Video reveals what text sources cannot: facility scale, team composition, product demonstrations, signage, event attendance, and operational reality.

ever-just/agentskills

Optimize and embed an existing video as a fast, crisp, autoplaying hero/background/loop on a website. Use when adding or replacing a video on a marketing site and it is too heavy, will not autoplay (especially on mobile/Safari), shows a codec error, or looks soft — to transcode it to web-safe H.264 with the right pixel format, faststart, retina-aware sizing, and a poster frame, then embed and verify it actually plays. This is optimization + embedding of footage you already have, not creating/animating a video (for that use remotion/moviepy/motion-canvas). Use when the user says "add this video to the site", "the hero video is too big / won't play / isn't crisp", "replace the homepage video", or "make this loop on the landing page".

ever-just/agentskills

Full conversion audit for any homepage or landing page. Use when someone asks to "review my homepage," "audit my landing page," "why isn't my page converting," "check my website," or wants feedback on their marketing page. Requires URL or screenshot before proceeding.

ever-just/agentskills

Automatically fetch YouTube video transcripts, generate structured summaries, and send full transcripts to messaging platforms. Detects YouTube URLs and provides metadata, key insights, and downloadable transcripts.

相关技能