Skip to content

Commit a78b470

Browse files
committed
deploy: 05d334f
0 parents  commit a78b470

427 files changed

Lines changed: 82385 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
## Captions
13+
14+
When dealing with captions or subtitles, load the [./rules/subtitles.md](./rules/subtitles.md) file for more information.
15+
16+
## Using FFmpeg
17+
18+
For some video operations, such as trimming videos or detecting silence, FFmpeg should be used. Load the [./rules/ffmpeg.md](./rules/ffmpeg.md) file for more information.
19+
20+
## Audio visualization
21+
22+
When needing to visualize audio (spectrum bars, waveforms, bass-reactive effects), load the [./rules/audio-visualization.md](./rules/audio-visualization.md) file for more information.
23+
24+
## Sound effects
25+
26+
When needing to use sound effects, load the [./rules/sound-effects.md](./rules/sound-effects.md) file for more information.
27+
28+
## How to use
29+
30+
Read individual rule files for detailed explanations and code examples:
31+
32+
- [rules/3d.md](rules/3d.md) - 3D content in Remotion using Three.js and React Three Fiber
33+
- [rules/animations.md](rules/animations.md) - Fundamental animation skills for Remotion
34+
- [rules/assets.md](rules/assets.md) - Importing images, videos, audio, and fonts into Remotion
35+
- [rules/audio.md](rules/audio.md) - Using audio and sound in Remotion - importing, trimming, volume, speed, pitch
36+
- [rules/calculate-metadata.md](rules/calculate-metadata.md) - Dynamically set composition duration, dimensions, and props
37+
- [rules/can-decode.md](rules/can-decode.md) - Check if a video can be decoded by the browser using Mediabunny
38+
- [rules/charts.md](rules/charts.md) - Chart and data visualization patterns for Remotion (bar, pie, line, stock charts)
39+
- [rules/compositions.md](rules/compositions.md) - Defining compositions, stills, folders, default props and dynamic metadata
40+
- [rules/extract-frames.md](rules/extract-frames.md) - Extract frames from videos at specific timestamps using Mediabunny
41+
- [rules/fonts.md](rules/fonts.md) - Loading Google Fonts and local fonts in Remotion
42+
- [rules/get-audio-duration.md](rules/get-audio-duration.md) - Getting the duration of an audio file in seconds with Mediabunny
43+
- [rules/get-video-dimensions.md](rules/get-video-dimensions.md) - Getting the width and height of a video file with Mediabunny
44+
- [rules/get-video-duration.md](rules/get-video-duration.md) - Getting the duration of a video file in seconds with Mediabunny
45+
- [rules/gifs.md](rules/gifs.md) - Displaying GIFs synchronized with Remotion's timeline
46+
- [rules/images.md](rules/images.md) - Embedding images in Remotion using the Img component
47+
- [rules/light-leaks.md](rules/light-leaks.md) - Light leak overlay effects using @remotion/light-leaks
48+
- [rules/lottie.md](rules/lottie.md) - Embedding Lottie animations in Remotion
49+
- [rules/measuring-dom-nodes.md](rules/measuring-dom-nodes.md) - Measuring DOM element dimensions in Remotion
50+
- [rules/measuring-text.md](rules/measuring-text.md) - Measuring text dimensions, fitting text to containers, and checking overflow
51+
- [rules/sequencing.md](rules/sequencing.md) - Sequencing patterns for Remotion - delay, trim, limit duration of items
52+
- [rules/tailwind.md](rules/tailwind.md) - Using TailwindCSS in Remotion
53+
- [rules/text-animations.md](rules/text-animations.md) - Typography and text animation patterns for Remotion
54+
- [rules/timing.md](rules/timing.md) - Interpolation curves in Remotion - linear, easing, spring animations
55+
- [rules/transitions.md](rules/transitions.md) - Scene transition patterns for Remotion
56+
- [rules/transparent-videos.md](rules/transparent-videos.md) - Rendering out a video with transparency
57+
- [rules/trimming.md](rules/trimming.md) - Trimming patterns for Remotion - cut the beginning or end of animations
58+
- [rules/videos.md](rules/videos.md) - Embedding videos in Remotion - trimming, volume, speed, looping, pitch
59+
- [rules/parameters.md](rules/parameters.md) - Make a video parametrizable by adding a Zod schema
60+
- [rules/maps.md](rules/maps.md) - Add a map using Mapbox and animate it
61+
- [rules/voiceover.md](rules/voiceover.md) - Adding AI-generated voiceover to Remotion compositions using ElevenLabs TTS
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: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 <div style={{ opacity }}>Hello World!</div>;
23+
};
24+
```
25+
26+
CSS transitions or animations are FORBIDDEN - they will not render correctly.
27+
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)