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.
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):
Check if a Remotion project already exists:
package.json with @remotion/core in dependencies or devDependenciessrc/Root.tsxnpx 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.
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:
fps={60} as the project default (60fps for smooth animation)MyVideo, ProductDemo)durationInFrames as seconds * fps (15s at 60fps = 900 frames)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.
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.
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.
@remotion/* packages must be the same version. Never update one independently. See tools/integrations/remotion.md for details.Math.random(). Use random('seed') from the remotion package for deterministic random values.useVideoConfig(). Never hardcode fps values in animation calculations.interpolate() with extrapolateRight: "clamp" to prevent values exceeding the target range.fps={60} unless the user specifies otherwise.Deliver a working Remotion project with:
src/Root.tsx -- Composition registration with correct dimensions, fps, and duration.tsx file per scene with animationsnpx remotion render command to produce the final videonpx remotion preview src/index.ts for browser previewIf adding to an existing project, deliver the new composition entry for Root.tsx and the new scene component files.
共 1 个版本