← 返回
未分类 中文

Remotion Best Practices

When the user wants to create videos programmatically with React using Remotion. Also use when the user mentions 'create video,' 'Remotion,' 'React video,' '...
当用户希望使用 React 与 Remotion 编程方式创建视频时使用,也适用于提及“创建视频”、Remotion、React 视频等关键词的情况。
mariokarras
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 1
Stars
📥 591
下载
💾 24
安装
1
版本
#latest

概述

Remotion Best Practices

You help users create videos programmatically using React and Remotion. Your goal is to scaffold projects, write compositions, build animated scene components, and render final video output -- all following Remotion v4 conventions and best practices.

Before Starting

Check for product marketing context first:

If .agents/product-marketing-context.md exists (or .claude/product-marketing-context.md in older setups), read it before asking questions. Use that context and only ask for information not already covered or specific to this task.

Understand what the user needs (ask if not provided):

  1. What video to create -- subject, purpose, and visual style
  2. Target duration and dimensions -- e.g., 15 seconds at 1920x1080
  3. New or existing project -- whether to scaffold fresh or add to an existing Remotion project

Workflow

Step 1: Set Up Project

Check if a Remotion project already exists:

  • Look for package.json with @remotion/core in dependencies or devDependencies
  • If found: skip scaffolding and add a new composition to the existing src/Root.tsx
  • If not found: scaffold a new project:
npx create-video@latest my-video

After scaffolding, verify all @remotion/* packages are on the same version:

npm ls | grep remotion

For detailed setup configuration, read references/setup.md.

Step 2: Define Composition in Root.tsx

Register your video as a Composition in src/Root.tsx:

import { Composition } from "remotion";
import { MyScene } from "./MyScene";

export const RemotionRoot: React.FC = () => {
  return (
    <Composition
      id="MyVideo"
      component={MyScene}
      durationInFrames={900}  // 15s at 60fps
      fps={60}
      width={1920}
      height={1080}
      defaultProps={{ title: "My Video" }}
    />
  );
};

Key points:

  • Use fps={60} as the project default (60fps for smooth animation)
  • Use PascalCase for composition IDs (e.g., MyVideo, ProductDemo)
  • Calculate durationInFrames as seconds * fps (15s at 60fps = 900 frames)

Step 3: Build Scene Components

Use AbsoluteFill as the root layout container. Use useCurrentFrame() and useVideoConfig() for animation state. Use for timeline positioning.

Minimal animated component:

import { useCurrentFrame, useVideoConfig, interpolate, AbsoluteFill } from "remotion";

export const MyScene: React.FC<{ title: string }> = ({ title }) => {
  const frame = useCurrentFrame();
  const { fps } = useVideoConfig();
  const opacity = interpolate(frame, [0, 30], [0, 1], {
    extrapolateRight: "clamp",
  });

  return (
    <AbsoluteFill style={{ justifyContent: "center", alignItems: "center" }}>
      <h1 style={{ opacity, fontSize: 80, color: "white" }}>{title}</h1>
    </AbsoluteFill>
  );
};

For physics-based animation, use spring():

import { spring } from "remotion";

const scale = spring({
  frame,
  fps,
  config: { damping: 12, stiffness: 100 },
});

For detailed animation patterns including spring() configuration, multi-step interpolation, and easing functions, read references/animations.md.

Step 4: Add Multi-Scene Timeline

Use to compose multiple scenes on a timeline:

import { Sequence, AbsoluteFill } from "remotion";

export const MyVideo: React.FC = () => {
  return (
    <AbsoluteFill style={{ backgroundColor: "black" }}>
      <Sequence durationInFrames={180}>
        <IntroScene />
      </Sequence>
      <Sequence from={180} durationInFrames={600}>
        <MainContent />
      </Sequence>
      <Sequence from={780} durationInFrames={120}>
        <OutroScene />
      </Sequence>
    </AbsoluteFill>
  );
};

Each resets useCurrentFrame() to 0 for its children, so each scene animates independently. The from prop sets when the scene starts on the parent timeline.

Step 5: Render Video

Preview in browser:

npx remotion preview src/index.ts

Render locally:

npx remotion render src/index.ts MyVideo out/video.mp4

Render with custom props:

npx remotion render src/index.ts MyVideo out/video.mp4 --props='{"title":"Hello"}'

For output formats, quality settings, and advanced render options, read references/rendering.md.

For AWS Lambda rendering at scale, read references/lambda.md.

See tools/integrations/remotion.md for the full CLI command reference.

Key Rules

  1. Version pinning -- All @remotion/* packages must be the same version. Never update one independently. See tools/integrations/remotion.md for details.
  2. Deterministic rendering -- Never use Math.random(). Use random('seed') from the remotion package for deterministic random values.
  3. FPS from config -- Always get fps from useVideoConfig(). Never hardcode fps values in animation calculations.
  4. Clamp interpolation -- Use interpolate() with extrapolateRight: "clamp" to prevent values exceeding the target range.
  5. Default 60fps -- All compositions use fps={60} unless the user specifies otherwise.

Output Format

Deliver a working Remotion project with:

  1. src/Root.tsx -- Composition registration with correct dimensions, fps, and duration
  2. Scene components -- One .tsx file per scene with animations
  3. Render command -- The exact npx remotion render command to produce the final video
  4. Preview command -- npx remotion preview src/index.ts for browser preview

If adding to an existing project, deliver the new composition entry for Root.tsx and the new scene component files.

Related Skills

  • video-ad-creation: Standard ad format compositions (15s/30s/60s) with product showcase templates
  • social-video-content: Social platform video formats (9:16 vertical, 1:1 square, 16:9 landscape)

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 12:18 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Exa X Search

mariokarras
在Twitter/X上搜索主题、人物或品牌的推文、讨论和情感倾向,使用Exa推文类别搜索功能。
★ 0 📥 629

Market Research

mariokarras
通过搜索报告、新闻、趋势和市场数据进行市场调研和行业分析。当用户提到市场调研、行业分析等相关需求时使用。
★ 0 📥 639

Social Content

mariokarras
帮助用户在LinkedIn、Twitter/X、Instagram、TikTok、Facebook等社交平台上创建、安排或优化内容。
★ 0 📥 616