Remotion Reference
Comprehensive Remotion API reference with best practices. This skill supplements carocut-builder-compositor with detailed API documentation.
Relationship to other skills:
- carocut-builder-compositor: Implementation patterns, visual standards, project structure
- carocut-reviewer: Debugging, preview, render commands
- This skill: Remotion API reference, component documentation
Critical Rules (MANDATORY)
| Rule |
Implementation |
Why |
| Frame calculation |
Always Math.round(sec * fps) |
Float frames cause jitter/crashes |
| interpolate safety |
Math.max(duration, 1) for inputRange |
Equal values crash Remotion |
| extrapolate clamp |
Always add extrapolateLeft/Right: 'clamp' |
Prevents values outside range |
| CSS animations |
FORBIDDEN |
Frame-inaccurate, breaks render |
| Native HTML media |
FORBIDDEN - use <Img>, <Audio>, <Video> |
Remotion needs asset tracking |
| setTimeout/setInterval |
FORBIDDEN |
Not frame-synchronized |
| useEffect side effects |
FORBIDDEN |
Breaks deterministic rendering |
Quick Reference
Core Hooks
| Hook |
Returns |
Usage |
useCurrentFrame() |
number |
Current frame (0-indexed) |
useVideoConfig() |
{ fps, width, height, durationInFrames } |
Video configuration |
Animation Functions
| Function |
Signature |
Purpose |
interpolate |
interpolate(frame, inputRange, outputRange, options) |
Linear interpolation |
spring |
spring({ frame, fps, config }) |
Physics-based animation |
Easing |
Easing.out(Easing.cubic) |
Easing curves |
Components
| Component |
Props |
Purpose |
<Sequence> |
from, durationInFrames, premountFor, name |
Time-based children |
<Series> |
children |
Sequential playback |
<AbsoluteFill> |
style |
Full-frame container |
<Img> |
src |
Image (use with staticFile) |
<Audio> |
src, volume, startFrom |
Audio playback |
<Video> |
src, startFrom, endAt |
Video playback |
<OffthreadVideo> |
src |
Memory-efficient video |
Utility Functions
| Function |
Usage |
staticFile("path") |
Reference public/ assets |
delayRender() |
Pause render until ready |
continueRender(handle) |
Resume after delayRender |
getInputProps() |
Get CLI input props |
References Directory
Detailed documentation organized by category. Load specific files when needed.
Core Concepts
| Topic |
File |
When to Use |
| Compositions |
references/compositions.md |
Defining compositions, registerRoot |
| Sequencing |
references/sequencing.md |
Sequence, Series, TransitionSeries |
| Timing |
references/timing.md |
Easing functions, spring config |
| Animations |
references/animations.md |
interpolate patterns, motion |
| Parameters |
references/parameters.md |
Zod schemas, input props |
| Calculate Metadata |
references/calculate-metadata.md |
Dynamic duration/dimensions |
Media Components
| Topic |
File |
When to Use |
| Images |
references/images.md |
Img component, sizing |
| Videos |
references/videos.md |
Video component, playback |
| Audio |
references/audio.md |
Sound, volume curves, trimming |
| GIFs |
references/gifs.md |
Animated GIF playback |
| Transparent Videos |
references/transparent-videos.md |
Alpha channel, WebM |
Assets and Resources
| Topic |
File |
When to Use |
| Assets |
references/assets.md |
staticFile, importing |
| Fonts |
references/fonts.md |
Google Fonts, local fonts, @font-face |
| Trimming |
references/trimming.md |
Cut audio/video start/end |
Text and Typography
| Topic |
File |
When to Use |
| Text Animations |
references/text-animations.md |
Typewriter, word-by-word |
| Measuring Text |
references/measuring-text.md |
Text dimensions, overflow |
| Measuring DOM Nodes |
references/measuring-dom-nodes.md |
Element size calculation |
Captions and Subtitles
| Topic |
File |
When to Use |
| Subtitles |
references/subtitles.md |
Caption display basics |
| Display Captions |
references/display-captions.md |
Styled caption rendering |
| Import SRT Captions |
references/import-srt-captions.md |
Parse SRT files |
| Transcribe Captions |
references/transcribe-captions.md |
Audio-to-text |
Visual Effects
| Topic |
File |
When to Use |
| Transitions |
references/transitions.md |
Scene transitions, TransitionSeries |
| Light Leaks |
references/light-leaks.md |
Overlay light effects |
| Lottie |
references/lottie.md |
After Effects animations |
Data Visualization
| Topic |
File |
When to Use |
| Charts |
references/charts.md |
Recharts integration |
| Maps |
references/maps.md |
Mapbox, geographic data |
Advanced Features
| Topic |
File |
When to Use |
| 3D |
references/3d.md |
Three.js, React Three Fiber |
| Tailwind |
references/tailwind.md |
Tailwind CSS integration |
| Can Decode |
references/can-decode.md |
Check codec support |
| Extract Frames |
references/extract-frames.md |
Get frames from video |
| Get Video Duration |
references/get-video-duration.md |
Query video length |
| Get Video Dimensions |
references/get-video-dimensions.md |
Query video size |
| Get Audio Duration |
references/get-audio-duration.md |
Query audio length |
Common Patterns
interpolate with Safety
// ALWAYS include clamp options
const opacity = interpolate(
frame,
[startFrame, endFrame],
[0, 1],
{ extrapolateLeft: 'clamp', extrapolateRight: 'clamp' }
);
// ALWAYS ensure minimum 1-frame duration
const duration = Math.max(secToFrames(text.length * 0.02), 1);
Staggered Entry Animation
{items.map((item, index) => {
const delay = 0.5 + index * 0.12;
const startFrame = Math.round(delay * fps);
const endFrame = Math.round((delay + 0.3) * fps);
const opacity = interpolate(
frame,
[startFrame, endFrame],
[0, 1],
{ extrapolateLeft: 'clamp', extrapolateRight: 'clamp' }
);
const translateY = interpolate(
frame,
[startFrame, endFrame],
[20, 0],
{ extrapolateLeft: 'clamp', extrapolateRight: 'clamp' }
);
return (
<div key={index} style={{ opacity, transform: `translateY(${translateY}px)` }}>
{item}
</div>
);
})}
Spring Animation
const { fps } = useVideoConfig();
const scale = spring({
frame,
fps,
config: {
damping: 12,
stiffness: 100,
mass: 0.5,
},
});
BGM with Fade In/Out
const { durationInFrames } = useVideoConfig();
const fadeInFrames = 60; // 2 seconds at 30fps
const fadeOutFrames = 90; // 3 seconds
<Audio
src={staticFile('audio/bgm/ambient.mp3')}
volume={(f) => interpolate(
f,
[0, fadeInFrames, durationInFrames - fadeOutFrames, durationInFrames],
[0, 0.15, 0.15, 0],
{ extrapolateLeft: 'clamp', extrapolateRight: 'clamp' }
)}
loop
/>
Voiceover Positioning
// Absolute positioning - NOT nested Sequences
const voStartFrame = computeShotStartFrame('shot_005') + msToFrames(200);
<Sequence from={voStartFrame} durationInFrames={msToFrames(voDuration)} name="Shot-005">
<Audio src={staticFile('audio/vo/VO_005.wav')} />
</Sequence>
TransitionSeries Usage
import { TransitionSeries, linearTiming } from '@remotion/transitions';
import { fade } from '@remotion/transitions/fade';
<TransitionSeries>
<TransitionSeries.Sequence durationInFrames={CHAPTER1_DURATION}>
<Chapter1 />
</TransitionSeries.Sequence>
<TransitionSeries.Transition
presentation={fade()}
timing={linearTiming({ durationInFrames: 15 })}
/>
<TransitionSeries.Sequence durationInFrames={CHAPTER2_DURATION}>
<Chapter2 />
</TransitionSeries.Sequence>
</TransitionSeries>
Frame Calculation Utilities
import { FPS } from './constants';
// Seconds to frames (always integer)
export function secToFrames(sec: number): number {
return Math.round(sec * FPS);
}
// Milliseconds to frames (always integer)
export function msToFrames(ms: number): number {
return Math.round((ms / 1000) * FPS);
}
// Safe duration (minimum 1 frame)
export function safeDuration(frames: number): number {
return Math.max(frames, 1);
}
Error Quick Reference
| Error Message |
Cause |
Fix |
inputRange must be strictly monotonically increasing |
Equal inputRange values |
Use Math.max(duration, 1) |
Could not find composition |
Missing registerRoot |
Check Root.tsx exports |
staticFile not found |
Wrong path |
Path relative to public/, case-sensitive |
Render timed out |
delayRender not continued |
Call continueRender() |
| White screen in Studio |
Component crash |
Check DevTools Console |
| WebGL render fails |
OpenGL flag |
Add renderer flag like--gl angle-egl |
Render Commands
All render output MUST go to the out/ directory so it appears in the resource panel.
# Test render (first 10 seconds)
npx remotion render MyComposition --frames=0-300 out/test.mp4
# Full render
npx remotion render MyComposition out/output.mp4
# High quality render
npx remotion render MyComposition --crf=15 out/output_hq.mp4
# Low memory render
npx remotion render MyComposition --concurrency=2 --gl=angle out/output.mp4
Notes
- This reference supplements carocut-builder-compositor, not replaces it
- For visual standards (fonts, colors, layout), see carocut-builder-compositor
- For debugging workflow, see carocut-reviewer
- Load specific rule files only when implementing that feature
1---2name: carocut-builder-remotion-ref3description: Remotion API 参考索引。包含 50+ 条 Remotion API 规则的目录索引、关键规则速查表、常用模式代码示例。加载此 skill 获取索引,然后按需 read 具体规则文件。是 carocut-builder-compositor 的伴侣参考。4---56# Remotion Reference78Comprehensive Remotion API reference with best practices. This skill supplements carocut-builder-compositor with detailed API documentation.910**Relationship to other skills:**11- **carocut-builder-compositor:** Implementation patterns, visual standards, project structure12- **carocut-reviewer:** Debugging, preview, render commands13- **This skill:** Remotion API reference, component documentation1415---1617## Critical Rules (MANDATORY)1819| Rule | Implementation | Why |20|------|----------------|-----|21| Frame calculation | Always `Math.round(sec * fps)` | Float frames cause jitter/crashes |22| interpolate safety | `Math.max(duration, 1)` for inputRange | Equal values crash Remotion |23| extrapolate clamp | Always add `extrapolateLeft/Right: 'clamp'` | Prevents values outside range |24| CSS animations | FORBIDDEN | Frame-inaccurate, breaks render |25| Native HTML media | FORBIDDEN - use `<Img>`, `<Audio>`, `<Video>` | Remotion needs asset tracking |26| setTimeout/setInterval | FORBIDDEN | Not frame-synchronized |27| useEffect side effects | FORBIDDEN | Breaks deterministic rendering |2829---3031## Quick Reference3233### Core Hooks3435| Hook | Returns | Usage |36|------|---------|-------|37| `useCurrentFrame()` | `number` | Current frame (0-indexed) |38| `useVideoConfig()` | `{ fps, width, height, durationInFrames }` | Video configuration |3940### Animation Functions4142| Function | Signature | Purpose |43|----------|-----------|---------|44| `interpolate` | `interpolate(frame, inputRange, outputRange, options)` | Linear interpolation |45| `spring` | `spring({ frame, fps, config })` | Physics-based animation |46| `Easing` | `Easing.out(Easing.cubic)` | Easing curves |4748### Components4950| Component | Props | Purpose |51|-----------|-------|---------|52| `<Sequence>` | `from`, `durationInFrames`, `premountFor`, `name` | Time-based children |53| `<Series>` | children | Sequential playback |54| `<AbsoluteFill>` | style | Full-frame container |55| `<Img>` | `src` | Image (use with staticFile) |56| `<Audio>` | `src`, `volume`, `startFrom` | Audio playback |57| `<Video>` | `src`, `startFrom`, `endAt` | Video playback |58| `<OffthreadVideo>` | `src` | Memory-efficient video |5960### Utility Functions6162| Function | Usage |63|----------|-------|64| `staticFile("path")` | Reference public/ assets |65| `delayRender()` | Pause render until ready |66| `continueRender(handle)` | Resume after delayRender |67| `getInputProps()` | Get CLI input props |6869---7071## References Directory7273Detailed documentation organized by category. Load specific files when needed.7475### Core Concepts7677| Topic | File | When to Use |78|-------|------|-------------|79| Compositions | `references/compositions.md` | Defining compositions, registerRoot |80| Sequencing | `references/sequencing.md` | Sequence, Series, TransitionSeries |81| Timing | `references/timing.md` | Easing functions, spring config |82| Animations | `references/animations.md` | interpolate patterns, motion |83| Parameters | `references/parameters.md` | Zod schemas, input props |84| Calculate Metadata | `references/calculate-metadata.md` | Dynamic duration/dimensions |8586### Media Components8788| Topic | File | When to Use |89|-------|------|-------------|90| Images | `references/images.md` | Img component, sizing |91| Videos | `references/videos.md` | Video component, playback |92| Audio | `references/audio.md` | Sound, volume curves, trimming |93| GIFs | `references/gifs.md` | Animated GIF playback |94| Transparent Videos | `references/transparent-videos.md` | Alpha channel, WebM |9596### Assets and Resources9798| Topic | File | When to Use |99|-------|------|-------------|100| Assets | `references/assets.md` | staticFile, importing |101| Fonts | `references/fonts.md` | Google Fonts, local fonts, @font-face |102| Trimming | `references/trimming.md` | Cut audio/video start/end |103104### Text and Typography105106| Topic | File | When to Use |107|-------|------|-------------|108| Text Animations | `references/text-animations.md` | Typewriter, word-by-word |109| Measuring Text | `references/measuring-text.md` | Text dimensions, overflow |110| Measuring DOM Nodes | `references/measuring-dom-nodes.md` | Element size calculation |111112### Captions and Subtitles113114| Topic | File | When to Use |115|-------|------|-------------|116| Subtitles | `references/subtitles.md` | Caption display basics |117| Display Captions | `references/display-captions.md` | Styled caption rendering |118| Import SRT Captions | `references/import-srt-captions.md` | Parse SRT files |119| Transcribe Captions | `references/transcribe-captions.md` | Audio-to-text |120121### Visual Effects122123| Topic | File | When to Use |124|-------|------|-------------|125| Transitions | `references/transitions.md` | Scene transitions, TransitionSeries |126| Light Leaks | `references/light-leaks.md` | Overlay light effects |127| Lottie | `references/lottie.md` | After Effects animations |128129### Data Visualization130131| Topic | File | When to Use |132|-------|------|-------------|133| Charts | `references/charts.md` | Recharts integration |134| Maps | `references/maps.md` | Mapbox, geographic data |135136### Advanced Features137138| Topic | File | When to Use |139|-------|------|-------------|140| 3D | `references/3d.md` | Three.js, React Three Fiber |141| Tailwind | `references/tailwind.md` | Tailwind CSS integration |142| Can Decode | `references/can-decode.md` | Check codec support |143| Extract Frames | `references/extract-frames.md` | Get frames from video |144| Get Video Duration | `references/get-video-duration.md` | Query video length |145| Get Video Dimensions | `references/get-video-dimensions.md` | Query video size |146| Get Audio Duration | `references/get-audio-duration.md` | Query audio length |147148---149150## Common Patterns151152### interpolate with Safety153154```typescript155// ALWAYS include clamp options156const opacity = interpolate(157 frame,158 [startFrame, endFrame],159 [0, 1],160 { extrapolateLeft: 'clamp', extrapolateRight: 'clamp' }161);162163// ALWAYS ensure minimum 1-frame duration164const duration = Math.max(secToFrames(text.length * 0.02), 1);165```166167### Staggered Entry Animation168169```typescript170{items.map((item, index) => {171 const delay = 0.5 + index * 0.12;172 const startFrame = Math.round(delay * fps);173 const endFrame = Math.round((delay + 0.3) * fps);174175 const opacity = interpolate(176 frame,177 [startFrame, endFrame],178 [0, 1],179 { extrapolateLeft: 'clamp', extrapolateRight: 'clamp' }180 );181 const translateY = interpolate(182 frame,183 [startFrame, endFrame],184 [20, 0],185 { extrapolateLeft: 'clamp', extrapolateRight: 'clamp' }186 );187188 return (189 <div key={index} style={{ opacity, transform: `translateY(${translateY}px)` }}>190 {item}191 </div>192 );193})}194```195196### Spring Animation197198```typescript199const { fps } = useVideoConfig();200const scale = spring({201 frame,202 fps,203 config: {204 damping: 12,205 stiffness: 100,206 mass: 0.5,207 },208});209```210211### BGM with Fade In/Out212213```typescript214const { durationInFrames } = useVideoConfig();215const fadeInFrames = 60; // 2 seconds at 30fps216const fadeOutFrames = 90; // 3 seconds217218<Audio219 src={staticFile('audio/bgm/ambient.mp3')}220 volume={(f) => interpolate(221 f,222 [0, fadeInFrames, durationInFrames - fadeOutFrames, durationInFrames],223 [0, 0.15, 0.15, 0],224 { extrapolateLeft: 'clamp', extrapolateRight: 'clamp' }225 )}226 loop227/>228```229230### Voiceover Positioning231232```typescript233// Absolute positioning - NOT nested Sequences234const voStartFrame = computeShotStartFrame('shot_005') + msToFrames(200);235236<Sequence from={voStartFrame} durationInFrames={msToFrames(voDuration)} name="Shot-005">237 <Audio src={staticFile('audio/vo/VO_005.wav')} />238</Sequence>239```240241### TransitionSeries Usage242243```typescript244import { TransitionSeries, linearTiming } from '@remotion/transitions';245import { fade } from '@remotion/transitions/fade';246247<TransitionSeries>248 <TransitionSeries.Sequence durationInFrames={CHAPTER1_DURATION}>249 <Chapter1 />250 </TransitionSeries.Sequence>251252 <TransitionSeries.Transition253 presentation={fade()}254 timing={linearTiming({ durationInFrames: 15 })}255 />256257 <TransitionSeries.Sequence durationInFrames={CHAPTER2_DURATION}>258 <Chapter2 />259 </TransitionSeries.Sequence>260</TransitionSeries>261```262263---264265## Frame Calculation Utilities266267```typescript268import { FPS } from './constants';269270// Seconds to frames (always integer)271export function secToFrames(sec: number): number {272 return Math.round(sec * FPS);273}274275// Milliseconds to frames (always integer)276export function msToFrames(ms: number): number {277 return Math.round((ms / 1000) * FPS);278}279280// Safe duration (minimum 1 frame)281export function safeDuration(frames: number): number {282 return Math.max(frames, 1);283}284```285286---287288## Error Quick Reference289290| Error Message | Cause | Fix |291|---------------|-------|-----|292| `inputRange must be strictly monotonically increasing` | Equal inputRange values | Use `Math.max(duration, 1)` |293| `Could not find composition` | Missing registerRoot | Check Root.tsx exports |294| `staticFile not found` | Wrong path | Path relative to public/, case-sensitive |295| `Render timed out` | delayRender not continued | Call continueRender() |296| White screen in Studio | Component crash | Check DevTools Console |297| WebGL render fails | OpenGL flag | Add renderer flag like`--gl angle-egl` |298299---300301## Render Commands302303All render output MUST go to the `out/` directory so it appears in the resource panel.304305```bash306# Test render (first 10 seconds)307npx remotion render MyComposition --frames=0-300 out/test.mp4308309# Full render310npx remotion render MyComposition out/output.mp4311312# High quality render313npx remotion render MyComposition --crf=15 out/output_hq.mp4314315# Low memory render316npx remotion render MyComposition --concurrency=2 --gl=angle out/output.mp4317```318319---320321## Notes322323- This reference supplements carocut-builder-compositor, not replaces it324- For visual standards (fonts, colors, layout), see carocut-builder-compositor325- For debugging workflow, see carocut-reviewer326- Load specific rule files only when implementing that feature