Skip to content

Commit b47ce4c

Browse files
authored
feat: add skills to bolt-remotion (#99)
1 parent 0532ff4 commit b47ce4c

32 files changed

+3130
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: remotion-best-practices
3+
description: Best practices for Remotion - Video creation in React
4+
metadata:
5+
tags: remotion, video, react, animation, composition
6+
---
7+
8+
## When to use
9+
10+
Use this skills whenever you are dealing with Remotion code to obtain the domain-specific knowledge.
11+
12+
## How to use
13+
14+
Read individual rule files for detailed explanations and code examples:
15+
16+
- [rules/3d.md](rules/3d.md) - 3D content in Remotion using Three.js and React Three Fiber
17+
- [rules/animations.md](rules/animations.md) - Fundamental animation skills for Remotion
18+
- [rules/assets.md](rules/assets.md) - Importing images, videos, audio, and fonts into Remotion
19+
- [rules/audio.md](rules/audio.md) - Using audio and sound in Remotion - importing, trimming, volume, speed, pitch
20+
- [rules/calculate-metadata.md](rules/calculate-metadata.md) - Dynamically set composition duration, dimensions, and props
21+
- [rules/can-decode.md](rules/can-decode.md) - Check if a video can be decoded by the browser using Mediabunny
22+
- [rules/charts.md](rules/charts.md) - Chart and data visualization patterns for Remotion
23+
- [rules/compositions.md](rules/compositions.md) - Defining compositions, stills, folders, default props and dynamic metadata
24+
- [rules/display-captions.md](rules/display-captions.md) - Displaying captions in Remotion with TikTok-style pages and word highlighting
25+
- [rules/extract-frames.md](rules/extract-frames.md) - Extract frames from videos at specific timestamps using Mediabunny
26+
- [rules/fonts.md](rules/fonts.md) - Loading Google Fonts and local fonts in Remotion
27+
- [rules/get-audio-duration.md](rules/get-audio-duration.md) - Getting the duration of an audio file in seconds with Mediabunny
28+
- [rules/get-video-dimensions.md](rules/get-video-dimensions.md) - Getting the width and height of a video file with Mediabunny
29+
- [rules/get-video-duration.md](rules/get-video-duration.md) - Getting the duration of a video file in seconds with Mediabunny
30+
- [rules/gifs.md](rules/gifs.md) - Displaying GIFs synchronized with Remotion's timeline
31+
- [rules/images.md](rules/images.md) - Embedding images in Remotion using the Img component
32+
- [rules/import-srt-captions.md](rules/import-srt-captions.md) - Importing .srt subtitle files into Remotion using @remotion/captions
33+
- [rules/lottie.md](rules/lottie.md) - Embedding Lottie animations in Remotion
34+
- [rules/measuring-dom-nodes.md](rules/measuring-dom-nodes.md) - Measuring DOM element dimensions in Remotion
35+
- [rules/measuring-text.md](rules/measuring-text.md) - Measuring text dimensions, fitting text to containers, and checking overflow
36+
- [rules/sequencing.md](rules/sequencing.md) - Sequencing patterns for Remotion - delay, trim, limit duration of items
37+
- [rules/tailwind.md](rules/tailwind.md) - Using TailwindCSS in Remotion
38+
- [rules/text-animations.md](rules/text-animations.md) - Typography and text animation patterns for Remotion
39+
- [rules/timing.md](rules/timing.md) - Interpolation curves in Remotion - linear, easing, spring animations
40+
- [rules/transcribe-captions.md](rules/transcribe-captions.md) - Transcribing audio to generate captions in Remotion
41+
- [rules/transitions.md](rules/transitions.md) - Scene transition patterns for Remotion
42+
- [rules/trimming.md](rules/trimming.md) - Trimming patterns for Remotion - cut the beginning or end of animations
43+
- [rules/videos.md](rules/videos.md) - Embedding videos in Remotion - trimming, volume, speed, looping, pitch
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
name: 3d
3+
description: 3D content in Remotion using Three.js and React Three Fiber.
4+
metadata:
5+
tags: 3d, three, threejs
6+
---
7+
8+
# Using Three.js and React Three Fiber in Remotion
9+
10+
Follow React Three Fiber and Three.js best practices.
11+
Only the following Remotion-specific rules need to be followed:
12+
13+
## Prerequisites
14+
15+
First, the `@remotion/three` package needs to be installed.
16+
If it is not, use the following command:
17+
18+
```bash
19+
npx remotion add @remotion/three # If project uses npm
20+
bunx remotion add @remotion/three # If project uses bun
21+
yarn remotion add @remotion/three # If project uses yarn
22+
pnpm exec remotion add @remotion/three # If project uses pnpm
23+
```
24+
25+
## Using ThreeCanvas
26+
27+
You MUST wrap 3D content in `<ThreeCanvas>` and include proper lighting.
28+
`<ThreeCanvas>` MUST have a `width` and `height` prop.
29+
30+
```tsx
31+
import { ThreeCanvas } from "@remotion/three";
32+
import { useVideoConfig } from "remotion";
33+
34+
const { width, height } = useVideoConfig();
35+
36+
<ThreeCanvas width={width} height={height}>
37+
<ambientLight intensity={0.4} />
38+
<directionalLight position={[5, 5, 5]} intensity={0.8} />
39+
<mesh>
40+
<sphereGeometry args={[1, 32, 32]} />
41+
<meshStandardMaterial color="red" />
42+
</mesh>
43+
</ThreeCanvas>
44+
```
45+
46+
## No animations not driven by `useCurrentFrame()`
47+
48+
Shaders, models etc MUST NOT animate by themselves.
49+
No animations are allowed unless they are driven by `useCurrentFrame()`.
50+
Otherwise, it will cause flickering during rendering.
51+
52+
Using `useFrame()` from `@react-three/fiber` is forbidden.
53+
54+
## Animate using `useCurrentFrame()`
55+
56+
Use `useCurrentFrame()` to perform animations.
57+
58+
```tsx
59+
const frame = useCurrentFrame();
60+
const rotationY = frame * 0.02;
61+
62+
<mesh rotation={[0, rotationY, 0]}>
63+
<boxGeometry args={[2, 2, 2]} />
64+
<meshStandardMaterial color="#4a9eff" />
65+
</mesh>
66+
```
67+
68+
## Using `<Sequence>` inside `<ThreeCanvas>`
69+
70+
The `layout` prop of any `<Sequence>` inside a `<ThreeCanvas>` must be set to `none`.
71+
72+
```tsx
73+
import { Sequence } from "remotion";
74+
import { ThreeCanvas } from "@remotion/three";
75+
76+
const { width, height } = useVideoConfig();
77+
78+
<ThreeCanvas width={width} height={height}>
79+
<Sequence layout="none">
80+
<mesh>
81+
<boxGeometry args={[2, 2, 2]} />
82+
<meshStandardMaterial color="#4a9eff" />
83+
</mesh>
84+
</Sequence>
85+
</ThreeCanvas>
86+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: animations
3+
description: Fundamental animation skills for Remotion
4+
metadata:
5+
tags: animations, transitions, frames, useCurrentFrame
6+
---
7+
8+
All animations MUST be driven by the `useCurrentFrame()` hook.
9+
Write animations in seconds and multiply them by the `fps` value from `useVideoConfig()`.
10+
11+
```tsx
12+
import { useCurrentFrame } from "remotion";
13+
14+
export const FadeIn = () => {
15+
const frame = useCurrentFrame();
16+
const { fps } = useVideoConfig();
17+
18+
const opacity = interpolate(frame, [0, 2 * fps], [0, 1], {
19+
extrapolateRight: 'clamp',
20+
});
21+
22+
return (
23+
<div style={{ opacity }}>Hello World!</div>
24+
);
25+
};
26+
```
27+
28+
CSS transitions or animations are FORBIDDEN - they will not render correctly.
29+
Tailwind animation class names are FORBIDDEN - they will not render correctly.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
name: assets
3+
description: Importing images, videos, audio, and fonts into Remotion
4+
metadata:
5+
tags: assets, staticFile, images, fonts, public
6+
---
7+
8+
# Importing assets in Remotion
9+
10+
## The public folder
11+
12+
Place assets in the `public/` folder at your project root.
13+
14+
## Using staticFile()
15+
16+
You MUST use `staticFile()` to reference files from the `public/` folder:
17+
18+
```tsx
19+
import {Img, staticFile} from 'remotion';
20+
21+
export const MyComposition = () => {
22+
return <Img src={staticFile('logo.png')} />;
23+
};
24+
```
25+
26+
The function returns an encoded URL that works correctly when deploying to subdirectories.
27+
28+
## Using with components
29+
30+
**Images:**
31+
32+
```tsx
33+
import {Img, staticFile} from 'remotion';
34+
35+
<Img src={staticFile('photo.png')} />;
36+
```
37+
38+
**Videos:**
39+
40+
```tsx
41+
import {Video} from '@remotion/media';
42+
import {staticFile} from 'remotion';
43+
44+
<Video src={staticFile('clip.mp4')} />;
45+
```
46+
47+
**Audio:**
48+
49+
```tsx
50+
import {Audio} from '@remotion/media';
51+
import {staticFile} from 'remotion';
52+
53+
<Audio src={staticFile('music.mp3')} />;
54+
```
55+
56+
**Fonts:**
57+
58+
```tsx
59+
import {staticFile} from 'remotion';
60+
61+
const fontFamily = new FontFace('MyFont', `url(${staticFile('font.woff2')})`);
62+
await fontFamily.load();
63+
document.fonts.add(fontFamily);
64+
```
65+
66+
## Remote URLs
67+
68+
Remote URLs can be used directly without `staticFile()`:
69+
70+
```tsx
71+
<Img src="https://example.com/image.png" />
72+
<Video src="https://remotion.media/video.mp4" />
73+
```
74+
75+
## Important notes
76+
77+
- Remotion components (`<Img>`, `<Video>`, `<Audio>`) ensure assets are fully loaded before rendering
78+
- Special characters in filenames (`#`, `?`, `&`) are automatically encoded

0 commit comments

Comments
 (0)