Communitygithub.com

ever-just/agentskills

使用 React 组件以编程方式创建视频。最成熟的代码驱动视频制作框架。

agentskills 是什么?

Remotion 是一个基于 React 和 TypeScript 的开源框架,允许开发者利用熟悉的 Web 技术栈(如组件、CSS 和动画库)以编程方式创建高质量视频。它提供了一整套核心概念,包括 Composition(定义视频尺寸、帧率和时长)、useCurrentFrame() 和 interpolate() 等动画基元、Sequence 和 Series 来组织时间线、以及丰富的过渡效果(如淡入、滑动、擦除)。通过 Remotion Studio 可以实时预览视频,并使用简单的 CLI 命令渲染为 MP4、GIF 或静止图像。该框架适用于生成动态视频内容、自动化视频生产流水线、以及创建可复用的视频模板,支持 Windows、macOS 和 Linux 平台。它的扩展生态包括 @remotion/transitions、@remotion/three(集成 React Three Fiber 3D 场景)和 @remotion/lottie(嵌入 Lottie 动画)等,所有扩展均为开源免费。

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

在你喜欢的 AI 中提问

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

文档

Remotion — 使用 React 以编程方式创建视频

使用 React 组件以编程方式创建视频。最成熟的代码驱动视频制作框架。

概述

  • 仓库: github.com/remotion-dev/remotion (21K+ 星标)
  • 语言: TypeScript / React
  • 许可证: 个人及年收入低于 100 万美元的公司免费
  • 安装: npm install remotion @remotion/cli @remotion/transitions
  • 文档: remotion.dev/docs

核心概念

组合(Composition)

<Composition> 定义了视频的尺寸、帧率和时长:

import { Composition } from "remotion";

export const RemotionRoot: React.FC = () => {
  return (
    <Composition
      id="MyVideo"
      component={MyVideo}
      durationInFrames={300}  // 30fps 下 10 秒
      fps={30}
      width={1920}
      height={1080}
    />
  );
};

动画基元

useCurrentFrame() — 返回当前帧编号(从 0 开始):

const frame = useCurrentFrame();

interpolate() — 将帧范围映射到输出值:

import { interpolate, useCurrentFrame } from "remotion";

const opacity = interpolate(frame, [0, 30], [0, 1], {
  extrapolateRight: "clamp",
});

spring() — 基于物理的弹簧动画:

import { spring, useCurrentFrame, useVideoConfig } from "remotion";

const { fps } = useVideoConfig();
const scale = spring({ frame, fps, config: { damping: 200 } });

时间线组织

— 将内容在时间上偏移:

<Sequence from={30} durationInFrames={60}>
  <MyScene />
</Sequence>

— 将子组件依次放置:

import { Series } from "remotion";

<Series>
  <Series.Sequence durationInFrames={90}>
    <IntroScene />
  </Series.Sequence>
  <Series.Sequence durationInFrames={150}>
    <MainScene />
  </Series.Sequence>
  <Series.Sequence durationInFrames={60}>
    <OutroScene />
  </Series.Sequence>
</Series>

— 全帧定位容器:

<AbsoluteFill style={{ backgroundColor: "#0a0a0a" }}>
  <h1>Hello World</h1>
</AbsoluteFill>

过渡效果

import { linearTiming, TransitionSeries } from "@remotion/transitions";
import { fade } from "@remotion/transitions/fade";
import { slide } from "@remotion/transitions/slide";

<TransitionSeries>
  <TransitionSeries.Sequence durationInFrames={90}>
    <Scene1 />
  </TransitionSeries.Sequence>
  <TransitionSeries.Transition
    presentation={fade()}
    timing={linearTiming({ durationInFrames: 15 })}
  />
  <TransitionSeries.Sequence durationInFrames={90}>
    <Scene2 />
  </TransitionSeries.Sequence>
</TransitionSeries>

可用的过渡效果:fade、slide、wipe、flip、clockWipe、none

媒体

import { Video, Audio, Img, staticFile } from "remotion";

// 静态文件放在 /public 目录下
<Video src={staticFile("demo.mp4")} />
<Audio src={staticFile("music.mp3")} volume={0.5} />
<Img src={staticFile("logo.png")} />

项目设置

# 创建新项目
npx create-video@latest my-video

# 或手动创建:
mkdir my-video && cd my-video
npm init -y
npm install remotion @remotion/cli @remotion/transitions react react-dom
npm install -D typescript @types/react

必需文件

src/index.ts(入口):

import { registerRoot } from "remotion";
import { RemotionRoot } from "./Root";
registerRoot(RemotionRoot);

remotion.config.ts:

import { Config } from "@remotion/cli/config";
Config.setVideoImageFormat("jpeg");
Config.setOverwriteOutput(true);

命令

# 在浏览器中预览(Remotion Studio)
npx remotion studio

# 渲染为 MP4
npx remotion render MyVideo out/video.mp4

# 渲染指定帧
npx remotion render MyVideo out/video.mp4 --frames=0-90

# 渲染为 GIF
npx remotion render MyVideo out/video.gif --image-format=png

# 渲染静止图像
npx remotion still MyVideo out/thumbnail.png --frame=45

最佳实践

  1. 始终钳制插值:使用 extrapolateRight: "clamp" 防止值溢出
  2. 使用 spring() 实现自然运动:弹簧效果比线性插值更自然
  3. 保持场景为独立组件:每个场景应是一个独立的 React 组件
  4. 使用 组织顺序场景:比手动计算偏移更简单
  5. 设置明确的时长:每个 Sequence 都应具有 durationInFrames
  6. 使用 AbsoluteFill:用于全帧背景和重叠层
  7. 静态资源放在 /public:使用 staticFile() 引用它们
  8. 在不同帧下测试:使用 Remotion Studio 的进度条来验证动画
  9. 优先使用 CSS 变换:transform: scale() 和 translateX() 是 GPU 加速的
  10. 避免大量重新渲染:使用 useMemo 缓存昂贵的计算

常见模式

淡入文本:

const frame = useCurrentFrame();
const opacity = interpolate(frame, [0, 20], [0, 1], { extrapolateRight: "clamp" });
const y = interpolate(frame, [0, 20], [20, 0], { extrapolateRight: "clamp" });

<div style={{ opacity, transform: `translateY(${y}px)` }}>
  Hello World
</div>

错列列表项:

{items.map((item, i) => {
  const delay = i * 8;
  const opacity = interpolate(frame, [delay, delay + 15], [0, 1], {
    extrapolateLeft: "clamp",
    extrapolateRight: "clamp",
  });
  return <div key={i} style={{ opacity }}>{item}</div>;
})}

打字机效果:

const charsShown = interpolate(frame, [0, text.length * 2], [0, text.length], {
  extrapolateRight: "clamp",
});
<span>{text.slice(0, Math.floor(charsShown))}</span>

扩展(全部开源,npm install)

  • @remotion/transitions — 场景过渡效果(淡入、滑动、擦除)
  • @remotion/three — 在视频中使用 React Three Fiber 3D 场景
  • @remotion/lottie — 嵌入 Lottie 动画
  • @remotion/gif — 嵌入 GIF 文件
  • @remotion/media-utils — 音频/视频元数据工具
  • @remotion/noise — 用于有机效果的 Perlin 噪声
  • @remotion/paths — SVG 路径动画工具

上游技能来源

  • 官方技能: github.com/remotion-dev/skills
  • 模板: github.com/reactvideoeditor/remotion-templates
  • Superpowers 流水线: github.com/dojocodinglabs/remotion-superpowers

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

> Add animated subtitles and captions to Remotion videos from .SRT files. TikTok-style word-by-word highlights, karaoke effects, and more.

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.

相关技能