remotion-claude-agent-demo 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +160 -0
  2. package/apps/web/README.md +36 -0
  3. package/apps/web/env.example +20 -0
  4. package/apps/web/eslint.config.mjs +18 -0
  5. package/apps/web/next.config.ts +7 -0
  6. package/apps/web/package-lock.json +10348 -0
  7. package/apps/web/package.json +35 -0
  8. package/apps/web/postcss.config.mjs +7 -0
  9. package/apps/web/public/file.svg +1 -0
  10. package/apps/web/public/globe.svg +1 -0
  11. package/apps/web/public/next.svg +1 -0
  12. package/apps/web/public/vercel.svg +1 -0
  13. package/apps/web/public/window.svg +1 -0
  14. package/apps/web/src/app/.well-known/agent-card.json/route.ts +50 -0
  15. package/apps/web/src/app/background-tasks/[jobId]/cancel/route.ts +29 -0
  16. package/apps/web/src/app/events/stream/route.ts +58 -0
  17. package/apps/web/src/app/favicon.ico +0 -0
  18. package/apps/web/src/app/globals.css +174 -0
  19. package/apps/web/src/app/layout.tsx +34 -0
  20. package/apps/web/src/app/messages/answer/route.ts +57 -0
  21. package/apps/web/src/app/messages/stream/route.ts +381 -0
  22. package/apps/web/src/app/page.tsx +358 -0
  23. package/apps/web/src/app/tasks/[taskId]/cancel/route.ts +24 -0
  24. package/apps/web/src/app/tasks/[taskId]/route.ts +24 -0
  25. package/apps/web/src/app/tasks/route.ts +13 -0
  26. package/apps/web/src/components/chat/agent-blocks.tsx +111 -0
  27. package/apps/web/src/components/chat/ask-user-question-panel.tsx +172 -0
  28. package/apps/web/src/components/chat/session-sidebar.tsx +222 -0
  29. package/apps/web/src/components/chat/subagent-activity-sidebar.tsx +248 -0
  30. package/apps/web/src/components/chat/tool-blocks.tsx +550 -0
  31. package/apps/web/src/lib/a2a/activity-store.ts +150 -0
  32. package/apps/web/src/lib/a2a/client.ts +357 -0
  33. package/apps/web/src/lib/a2a/sse.ts +19 -0
  34. package/apps/web/src/lib/a2a/task-store.ts +111 -0
  35. package/apps/web/src/lib/a2a/types.ts +216 -0
  36. package/apps/web/src/lib/agent/answer-store.ts +109 -0
  37. package/apps/web/src/lib/agent/background-delivery.ts +343 -0
  38. package/apps/web/src/lib/agent/background-tool.ts +78 -0
  39. package/apps/web/src/lib/agent/background.ts +452 -0
  40. package/apps/web/src/lib/agent/chat.ts +543 -0
  41. package/apps/web/src/lib/agent/session-store.ts +26 -0
  42. package/apps/web/src/lib/chat/types.ts +44 -0
  43. package/apps/web/src/lib/env.ts +31 -0
  44. package/apps/web/src/lib/hooks/useA2AChat.ts +863 -0
  45. package/apps/web/src/lib/state/chat-atoms.ts +52 -0
  46. package/apps/web/src/lib/workspace.ts +9 -0
  47. package/apps/web/tsconfig.json +35 -0
  48. package/bin/remotion-agent.js +451 -0
  49. package/package.json +34 -0
  50. package/templates/.claude/CLAUDE.md +95 -0
  51. package/templates/.claude/README.md +129 -0
  52. package/templates/.claude/agents/composer-agent.md +188 -0
  53. package/templates/.claude/agents/crafter.md +181 -0
  54. package/templates/.claude/agents/creator.md +134 -0
  55. package/templates/.claude/agents/perceiver.md +92 -0
  56. package/templates/.claude/settings.json +36 -0
  57. package/templates/.claude/settings.local.json +39 -0
  58. package/templates/.claude/skills/agent-browser/SKILL.md +349 -0
  59. package/templates/.claude/skills/agent-browser/references/authentication.md +188 -0
  60. package/templates/.claude/skills/agent-browser/references/proxy-support.md +175 -0
  61. package/templates/.claude/skills/agent-browser/references/session-management.md +181 -0
  62. package/templates/.claude/skills/agent-browser/references/snapshot-refs.md +186 -0
  63. package/templates/.claude/skills/agent-browser/references/video-recording.md +162 -0
  64. package/templates/.claude/skills/agent-browser/templates/authenticated-session.sh +91 -0
  65. package/templates/.claude/skills/agent-browser/templates/capture-workflow.sh +68 -0
  66. package/templates/.claude/skills/agent-browser/templates/form-automation.sh +64 -0
  67. package/templates/.claude/skills/algorithmic-art/LICENSE.txt +202 -0
  68. package/templates/.claude/skills/algorithmic-art/SKILL.md +405 -0
  69. package/templates/.claude/skills/algorithmic-art/templates/generator_template.js +223 -0
  70. package/templates/.claude/skills/algorithmic-art/templates/viewer.html +599 -0
  71. package/templates/.claude/skills/asset-validator/SKILL.md +376 -0
  72. package/templates/.claude/skills/audio-video-sync/SKILL.md +219 -0
  73. package/templates/.claude/skills/bgm-manager/SKILL.md +334 -0
  74. package/templates/.claude/skills/remotion-best-practices/SKILL.md +45 -0
  75. package/templates/.claude/skills/remotion-best-practices/rules/3d.md +86 -0
  76. package/templates/.claude/skills/remotion-best-practices/rules/animations.md +29 -0
  77. package/templates/.claude/skills/remotion-best-practices/rules/assets/charts-bar-chart.tsx +173 -0
  78. package/templates/.claude/skills/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +100 -0
  79. package/templates/.claude/skills/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +108 -0
  80. package/templates/.claude/skills/remotion-best-practices/rules/assets.md +78 -0
  81. package/templates/.claude/skills/remotion-best-practices/rules/audio.md +172 -0
  82. package/templates/.claude/skills/remotion-best-practices/rules/calculate-metadata.md +104 -0
  83. package/templates/.claude/skills/remotion-best-practices/rules/can-decode.md +75 -0
  84. package/templates/.claude/skills/remotion-best-practices/rules/charts.md +58 -0
  85. package/templates/.claude/skills/remotion-best-practices/rules/compositions.md +141 -0
  86. package/templates/.claude/skills/remotion-best-practices/rules/display-captions.md +126 -0
  87. package/templates/.claude/skills/remotion-best-practices/rules/extract-frames.md +229 -0
  88. package/templates/.claude/skills/remotion-best-practices/rules/fonts.md +152 -0
  89. package/templates/.claude/skills/remotion-best-practices/rules/get-audio-duration.md +58 -0
  90. package/templates/.claude/skills/remotion-best-practices/rules/get-video-dimensions.md +68 -0
  91. package/templates/.claude/skills/remotion-best-practices/rules/get-video-duration.md +58 -0
  92. package/templates/.claude/skills/remotion-best-practices/rules/gifs.md +138 -0
  93. package/templates/.claude/skills/remotion-best-practices/rules/images.md +130 -0
  94. package/templates/.claude/skills/remotion-best-practices/rules/import-srt-captions.md +67 -0
  95. package/templates/.claude/skills/remotion-best-practices/rules/lottie.md +68 -0
  96. package/templates/.claude/skills/remotion-best-practices/rules/maps.md +403 -0
  97. package/templates/.claude/skills/remotion-best-practices/rules/measuring-dom-nodes.md +35 -0
  98. package/templates/.claude/skills/remotion-best-practices/rules/measuring-text.md +143 -0
  99. package/templates/.claude/skills/remotion-best-practices/rules/parameters.md +98 -0
  100. package/templates/.claude/skills/remotion-best-practices/rules/sequencing.md +118 -0
  101. package/templates/.claude/skills/remotion-best-practices/rules/tailwind.md +11 -0
  102. package/templates/.claude/skills/remotion-best-practices/rules/text-animations.md +20 -0
  103. package/templates/.claude/skills/remotion-best-practices/rules/timing.md +179 -0
  104. package/templates/.claude/skills/remotion-best-practices/rules/transcribe-captions.md +19 -0
  105. package/templates/.claude/skills/remotion-best-practices/rules/transitions.md +122 -0
  106. package/templates/.claude/skills/remotion-best-practices/rules/trimming.md +53 -0
  107. package/templates/.claude/skills/remotion-best-practices/rules/videos.md +171 -0
  108. package/templates/.claude/skills/remotion-components/SKILL.md +453 -0
  109. package/templates/.claude/skills/render-config/SKILL.md +290 -0
  110. package/templates/.claude/skills/script-writer/SKILL.md +59 -0
  111. package/templates/.claude/skills/style-director/script-writer/SKILL.md +82 -0
  112. package/templates/.claude/skills/style-director/style-director/SKILL.md +287 -0
  113. package/templates/.claude/skills/style-director/style-director/references/audience-and-scenarios.md +43 -0
  114. package/templates/.claude/skills/style-director/style-director/references/interaction-innovation.md +26 -0
  115. package/templates/.claude/skills/style-director/style-director/references/motion-grammar.md +66 -0
  116. package/templates/.claude/skills/style-director/style-director/references/quality-checklist.md +29 -0
  117. package/templates/.claude/skills/style-director/style-director/references/scene-recipes.md +38 -0
  118. package/templates/.claude/skills/style-director/style-director/references/visual-style-system.md +148 -0
  119. package/templates/.claude/skills/subtitle-composer/SKILL.md +304 -0
  120. package/templates/.claude/skills/subtitle-processor/SKILL.md +308 -0
  121. package/templates/.claude/skills/timeline-generator/SKILL.md +253 -0
  122. package/templates/.claude/skills/video-preflight-check/SKILL.md +353 -0
  123. package/templates/.claude/skills/voice-synthesizer/SKILL.md +296 -0
  124. package/templates/.claude/skills/voice-synthesizer/scripts/synthesize_voice.py +315 -0
  125. package/templates/.claude/skills/voice-synthesizer/scripts/tts_cli.py +142 -0
  126. package/templates/.claude/skills/web-design-guidelines/SKILL.md +36 -0
  127. package/templates/.claude/skills/youtube-downloader/SKILL.md +99 -0
  128. package/templates/.claude/skills/youtube-downloader/scripts/download_video.py +145 -0
@@ -0,0 +1,100 @@
1
+ import {
2
+ AbsoluteFill,
3
+ interpolate,
4
+ useCurrentFrame,
5
+ useVideoConfig,
6
+ } from 'remotion';
7
+
8
+ const COLOR_BG = '#ffffff';
9
+ const COLOR_TEXT = '#000000';
10
+ const FULL_TEXT = 'From prompt to motion graphics. This is Remotion.';
11
+ const PAUSE_AFTER = 'From prompt to motion graphics.';
12
+ const FONT_SIZE = 72;
13
+ const FONT_WEIGHT = 700;
14
+ const CHAR_FRAMES = 2;
15
+ const CURSOR_BLINK_FRAMES = 16;
16
+ const PAUSE_SECONDS = 1;
17
+
18
+ // Ideal composition size: 1280x720
19
+
20
+ const getTypedText = ({
21
+ frame,
22
+ fullText,
23
+ pauseAfter,
24
+ charFrames,
25
+ pauseFrames,
26
+ }: {
27
+ frame: number;
28
+ fullText: string;
29
+ pauseAfter: string;
30
+ charFrames: number;
31
+ pauseFrames: number;
32
+ }): string => {
33
+ const pauseIndex = fullText.indexOf(pauseAfter);
34
+ const preLen =
35
+ pauseIndex >= 0 ? pauseIndex + pauseAfter.length : fullText.length;
36
+
37
+ let typedChars = 0;
38
+ if (frame < preLen * charFrames) {
39
+ typedChars = Math.floor(frame / charFrames);
40
+ } else if (frame < preLen * charFrames + pauseFrames) {
41
+ typedChars = preLen;
42
+ } else {
43
+ const postPhase = frame - preLen * charFrames - pauseFrames;
44
+ typedChars = Math.min(
45
+ fullText.length,
46
+ preLen + Math.floor(postPhase / charFrames),
47
+ );
48
+ }
49
+ return fullText.slice(0, typedChars);
50
+ };
51
+
52
+ const Cursor: React.FC<{
53
+ frame: number;
54
+ blinkFrames: number;
55
+ symbol?: string;
56
+ }> = ({frame, blinkFrames, symbol = '\u258C'}) => {
57
+ const opacity = interpolate(
58
+ frame % blinkFrames,
59
+ [0, blinkFrames / 2, blinkFrames],
60
+ [1, 0, 1],
61
+ {extrapolateLeft: 'clamp', extrapolateRight: 'clamp'},
62
+ );
63
+
64
+ return <span style={{opacity}}>{symbol}</span>;
65
+ };
66
+
67
+ export const MyAnimation = () => {
68
+ const frame = useCurrentFrame();
69
+ const {fps} = useVideoConfig();
70
+
71
+ const pauseFrames = Math.round(fps * PAUSE_SECONDS);
72
+
73
+ const typedText = getTypedText({
74
+ frame,
75
+ fullText: FULL_TEXT,
76
+ pauseAfter: PAUSE_AFTER,
77
+ charFrames: CHAR_FRAMES,
78
+ pauseFrames,
79
+ });
80
+
81
+ return (
82
+ <AbsoluteFill
83
+ style={{
84
+ backgroundColor: COLOR_BG,
85
+ }}
86
+ >
87
+ <div
88
+ style={{
89
+ color: COLOR_TEXT,
90
+ fontSize: FONT_SIZE,
91
+ fontWeight: FONT_WEIGHT,
92
+ fontFamily: 'sans-serif',
93
+ }}
94
+ >
95
+ <span>{typedText}</span>
96
+ <Cursor frame={frame} blinkFrames={CURSOR_BLINK_FRAMES} />
97
+ </div>
98
+ </AbsoluteFill>
99
+ );
100
+ };
@@ -0,0 +1,108 @@
1
+ import {loadFont} from '@remotion/google-fonts/Inter';
2
+ import React from 'react';
3
+ import {
4
+ AbsoluteFill,
5
+ spring,
6
+ useCurrentFrame,
7
+ useVideoConfig,
8
+ } from 'remotion';
9
+
10
+ /*
11
+ * Highlight a word in a sentence with a spring-animated wipe effect.
12
+ */
13
+
14
+ // Ideal composition size: 1280x720
15
+
16
+ const COLOR_BG = '#ffffff';
17
+ const COLOR_TEXT = '#000000';
18
+ const COLOR_HIGHLIGHT = '#A7C7E7';
19
+ const FULL_TEXT = 'This is Remotion.';
20
+ const HIGHLIGHT_WORD = 'Remotion';
21
+ const FONT_SIZE = 72;
22
+ const FONT_WEIGHT = 700;
23
+ const HIGHLIGHT_START_FRAME = 30;
24
+ const HIGHLIGHT_WIPE_DURATION = 18;
25
+
26
+ const {fontFamily} = loadFont();
27
+
28
+ const Highlight: React.FC<{
29
+ word: string;
30
+ color: string;
31
+ delay: number;
32
+ durationInFrames: number;
33
+ }> = ({word, color, delay, durationInFrames}) => {
34
+ const frame = useCurrentFrame();
35
+ const {fps} = useVideoConfig();
36
+
37
+ const highlightProgress = spring({
38
+ fps,
39
+ frame,
40
+ config: {damping: 200},
41
+ delay,
42
+ durationInFrames,
43
+ });
44
+ const scaleX = Math.max(0, Math.min(1, highlightProgress));
45
+
46
+ return (
47
+ <span style={{position: 'relative', display: 'inline-block'}}>
48
+ <span
49
+ style={{
50
+ position: 'absolute',
51
+ left: 0,
52
+ right: 0,
53
+ top: '50%',
54
+ height: '1.05em',
55
+ transform: `translateY(-50%) scaleX(${scaleX})`,
56
+ transformOrigin: 'left center',
57
+ backgroundColor: color,
58
+ borderRadius: '0.18em',
59
+ zIndex: 0,
60
+ }}
61
+ />
62
+ <span style={{position: 'relative', zIndex: 1}}>{word}</span>
63
+ </span>
64
+ );
65
+ };
66
+
67
+ export const MyAnimation = () => {
68
+ const highlightIndex = FULL_TEXT.indexOf(HIGHLIGHT_WORD);
69
+ const hasHighlight = highlightIndex >= 0;
70
+ const preText = hasHighlight ? FULL_TEXT.slice(0, highlightIndex) : FULL_TEXT;
71
+ const postText = hasHighlight
72
+ ? FULL_TEXT.slice(highlightIndex + HIGHLIGHT_WORD.length)
73
+ : '';
74
+
75
+ return (
76
+ <AbsoluteFill
77
+ style={{
78
+ backgroundColor: COLOR_BG,
79
+ alignItems: 'center',
80
+ justifyContent: 'center',
81
+ fontFamily,
82
+ }}
83
+ >
84
+ <div
85
+ style={{
86
+ color: COLOR_TEXT,
87
+ fontSize: FONT_SIZE,
88
+ fontWeight: FONT_WEIGHT,
89
+ }}
90
+ >
91
+ {hasHighlight ? (
92
+ <>
93
+ <span>{preText}</span>
94
+ <Highlight
95
+ word={HIGHLIGHT_WORD}
96
+ color={COLOR_HIGHLIGHT}
97
+ delay={HIGHLIGHT_START_FRAME}
98
+ durationInFrames={HIGHLIGHT_WIPE_DURATION}
99
+ />
100
+ <span>{postText}</span>
101
+ </>
102
+ ) : (
103
+ <span>{FULL_TEXT}</span>
104
+ )}
105
+ </div>
106
+ </AbsoluteFill>
107
+ );
108
+ };
@@ -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,0 +1,172 @@
1
+ ---
2
+ name: audio
3
+ description: Using audio and sound in Remotion - importing, trimming, volume, speed, pitch
4
+ metadata:
5
+ tags: audio, media, trim, volume, speed, loop, pitch, mute, sound, sfx
6
+ ---
7
+
8
+ # Using audio in Remotion
9
+
10
+ ## Prerequisites
11
+
12
+ First, the @remotion/media package needs to be installed.
13
+ If it is not installed, use the following command:
14
+
15
+ ```bash
16
+ npx remotion add @remotion/media # If project uses npm
17
+ bunx remotion add @remotion/media # If project uses bun
18
+ yarn remotion add @remotion/media # If project uses yarn
19
+ pnpm exec remotion add @remotion/media # If project uses pnpm
20
+ ```
21
+
22
+ ## Importing Audio
23
+
24
+ Use `<Audio>` from `@remotion/media` to add audio to your composition.
25
+
26
+ ```tsx
27
+ import { Audio } from "@remotion/media";
28
+ import { staticFile } from "remotion";
29
+
30
+ export const MyComposition = () => {
31
+ return <Audio src={staticFile("audio.mp3")} />;
32
+ };
33
+ ```
34
+
35
+ Remote URLs are also supported:
36
+
37
+ ```tsx
38
+ <Audio src="https://remotion.media/audio.mp3" />
39
+ ```
40
+
41
+ By default, audio plays from the start, at full volume and full length.
42
+ Multiple audio tracks can be layered by adding multiple `<Audio>` components.
43
+
44
+ ## Trimming
45
+
46
+ Use `trimBefore` and `trimAfter` to remove portions of the audio. Values are in frames.
47
+
48
+ ```tsx
49
+ const { fps } = useVideoConfig();
50
+
51
+ return (
52
+ <Audio
53
+ src={staticFile("audio.mp3")}
54
+ trimBefore={2 * fps} // Skip the first 2 seconds
55
+ trimAfter={10 * fps} // End at the 10 second mark
56
+ />
57
+ );
58
+ ```
59
+
60
+ The audio still starts playing at the beginning of the composition - only the specified portion is played.
61
+
62
+ ## Delaying
63
+
64
+ Wrap the audio in a `<Sequence>` to delay when it starts:
65
+
66
+ ```tsx
67
+ import { Sequence, staticFile } from "remotion";
68
+ import { Audio } from "@remotion/media";
69
+
70
+ const { fps } = useVideoConfig();
71
+
72
+ return (
73
+ <Sequence from={1 * fps}>
74
+ <Audio src={staticFile("audio.mp3")} />
75
+ </Sequence>
76
+ );
77
+ ```
78
+
79
+ The audio will start playing after 1 second.
80
+
81
+ ## Volume
82
+
83
+ Set a static volume (0 to 1):
84
+
85
+ ```tsx
86
+ <Audio src={staticFile("audio.mp3")} volume={0.5} />
87
+ ```
88
+
89
+ Or use a callback for dynamic volume based on the current frame:
90
+
91
+ ```tsx
92
+ import { interpolate } from "remotion";
93
+
94
+ const { fps } = useVideoConfig();
95
+
96
+ return (
97
+ <Audio
98
+ src={staticFile("audio.mp3")}
99
+ volume={(f) =>
100
+ interpolate(f, [0, 1 * fps], [0, 1], { extrapolateRight: "clamp" })
101
+ }
102
+ />
103
+ );
104
+ ```
105
+
106
+ The value of `f` starts at 0 when the audio begins to play, not the composition frame.
107
+
108
+ ## Muting
109
+
110
+ Use `muted` to silence the audio. It can be set dynamically:
111
+
112
+ ```tsx
113
+ const frame = useCurrentFrame();
114
+ const { fps } = useVideoConfig();
115
+
116
+ return (
117
+ <Audio
118
+ src={staticFile("audio.mp3")}
119
+ muted={frame >= 2 * fps && frame <= 4 * fps} // Mute between 2s and 4s
120
+ />
121
+ );
122
+ ```
123
+
124
+ ## Speed
125
+
126
+ Use `playbackRate` to change the playback speed:
127
+
128
+ ```tsx
129
+ <Audio src={staticFile("audio.mp3")} playbackRate={2} /> {/* 2x speed */}
130
+ <Audio src={staticFile("audio.mp3")} playbackRate={0.5} /> {/* Half speed */}
131
+ ```
132
+
133
+ Reverse playback is not supported.
134
+
135
+ ## Looping
136
+
137
+ Use `loop` to loop the audio indefinitely:
138
+
139
+ ```tsx
140
+ <Audio src={staticFile("audio.mp3")} loop />
141
+ ```
142
+
143
+ Use `loopVolumeCurveBehavior` to control how the frame count behaves when looping:
144
+
145
+ - `"repeat"`: Frame count resets to 0 each loop (default)
146
+ - `"extend"`: Frame count continues incrementing
147
+
148
+ ```tsx
149
+ <Audio
150
+ src={staticFile("audio.mp3")}
151
+ loop
152
+ loopVolumeCurveBehavior="extend"
153
+ volume={(f) => interpolate(f, [0, 300], [1, 0])} // Fade out over multiple loops
154
+ />
155
+ ```
156
+
157
+ ## Pitch
158
+
159
+ Use `toneFrequency` to adjust the pitch without affecting speed. Values range from 0.01 to 2:
160
+
161
+ ```tsx
162
+ <Audio
163
+ src={staticFile("audio.mp3")}
164
+ toneFrequency={1.5} // Higher pitch
165
+ />
166
+ <Audio
167
+ src={staticFile("audio.mp3")}
168
+ toneFrequency={0.8} // Lower pitch
169
+ />
170
+ ```
171
+
172
+ Pitch shifting only works during server-side rendering, not in the Remotion Studio preview or in the `<Player />`.
@@ -0,0 +1,104 @@
1
+ ---
2
+ name: calculate-metadata
3
+ description: Dynamically set composition duration, dimensions, and props
4
+ metadata:
5
+ tags: calculateMetadata, duration, dimensions, props, dynamic
6
+ ---
7
+
8
+ # Using calculateMetadata
9
+
10
+ Use `calculateMetadata` on a `<Composition>` to dynamically set duration, dimensions, and transform props before rendering.
11
+
12
+ ```tsx
13
+ <Composition id="MyComp" component={MyComponent} durationInFrames={300} fps={30} width={1920} height={1080} defaultProps={{videoSrc: 'https://remotion.media/video.mp4'}} calculateMetadata={calculateMetadata} />
14
+ ```
15
+
16
+ ## Setting duration based on a video
17
+
18
+ Use the `getMediaMetadata()` function from the mediabunny/metadata skill to get the video duration:
19
+
20
+ ```tsx
21
+ import {CalculateMetadataFunction} from 'remotion';
22
+ import {getMediaMetadata} from '../get-media-metadata';
23
+
24
+ const calculateMetadata: CalculateMetadataFunction<Props> = async ({props}) => {
25
+ const {durationInSeconds} = await getMediaMetadata(props.videoSrc);
26
+
27
+ return {
28
+ durationInFrames: Math.ceil(durationInSeconds * 30),
29
+ };
30
+ };
31
+ ```
32
+
33
+ ## Matching dimensions of a video
34
+
35
+ ```tsx
36
+ const calculateMetadata: CalculateMetadataFunction<Props> = async ({props}) => {
37
+ const {durationInSeconds, dimensions} = await getMediaMetadata(props.videoSrc);
38
+
39
+ return {
40
+ durationInFrames: Math.ceil(durationInSeconds * 30),
41
+ width: dimensions?.width ?? 1920,
42
+ height: dimensions?.height ?? 1080,
43
+ };
44
+ };
45
+ ```
46
+
47
+ ## Setting duration based on multiple videos
48
+
49
+ ```tsx
50
+ const calculateMetadata: CalculateMetadataFunction<Props> = async ({props}) => {
51
+ const metadataPromises = props.videos.map((video) => getMediaMetadata(video.src));
52
+ const allMetadata = await Promise.all(metadataPromises);
53
+
54
+ const totalDuration = allMetadata.reduce((sum, meta) => sum + meta.durationInSeconds, 0);
55
+
56
+ return {
57
+ durationInFrames: Math.ceil(totalDuration * 30),
58
+ };
59
+ };
60
+ ```
61
+
62
+ ## Setting a default outName
63
+
64
+ Set the default output filename based on props:
65
+
66
+ ```tsx
67
+ const calculateMetadata: CalculateMetadataFunction<Props> = async ({props}) => {
68
+ return {
69
+ defaultOutName: `video-${props.id}.mp4`,
70
+ };
71
+ };
72
+ ```
73
+
74
+ ## Transforming props
75
+
76
+ Fetch data or transform props before rendering:
77
+
78
+ ```tsx
79
+ const calculateMetadata: CalculateMetadataFunction<Props> = async ({props, abortSignal}) => {
80
+ const response = await fetch(props.dataUrl, {signal: abortSignal});
81
+ const data = await response.json();
82
+
83
+ return {
84
+ props: {
85
+ ...props,
86
+ fetchedData: data,
87
+ },
88
+ };
89
+ };
90
+ ```
91
+
92
+ The `abortSignal` cancels stale requests when props change in the Studio.
93
+
94
+ ## Return value
95
+
96
+ All fields are optional. Returned values override the `<Composition>` props:
97
+
98
+ - `durationInFrames`: Number of frames
99
+ - `width`: Composition width in pixels
100
+ - `height`: Composition height in pixels
101
+ - `fps`: Frames per second
102
+ - `props`: Transformed props passed to the component
103
+ - `defaultOutName`: Default output filename
104
+ - `defaultCodec`: Default codec for rendering
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: can-decode
3
+ description: Check if a video can be decoded by the browser using Mediabunny
4
+ metadata:
5
+ tags: decode, validation, video, audio, compatibility, browser
6
+ ---
7
+
8
+ # Checking if a video can be decoded
9
+
10
+ Use Mediabunny to check if a video can be decoded by the browser before attempting to play it.
11
+
12
+ ## The `canDecode()` function
13
+
14
+ This function can be copy-pasted into any project.
15
+
16
+ ```tsx
17
+ import { Input, ALL_FORMATS, UrlSource } from "mediabunny";
18
+
19
+ export const canDecode = async (src: string) => {
20
+ const input = new Input({
21
+ formats: ALL_FORMATS,
22
+ source: new UrlSource(src, {
23
+ getRetryDelay: () => null,
24
+ }),
25
+ });
26
+
27
+ try {
28
+ await input.getFormat();
29
+ } catch {
30
+ return false;
31
+ }
32
+
33
+ const videoTrack = await input.getPrimaryVideoTrack();
34
+ if (videoTrack && !(await videoTrack.canDecode())) {
35
+ return false;
36
+ }
37
+
38
+ const audioTrack = await input.getPrimaryAudioTrack();
39
+ if (audioTrack && !(await audioTrack.canDecode())) {
40
+ return false;
41
+ }
42
+
43
+ return true;
44
+ };
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ ```tsx
50
+ const src = "https://remotion.media/video.mp4";
51
+ const isDecodable = await canDecode(src);
52
+
53
+ if (isDecodable) {
54
+ console.log("Video can be decoded");
55
+ } else {
56
+ console.log("Video cannot be decoded by this browser");
57
+ }
58
+ ```
59
+
60
+ ## Using with Blob
61
+
62
+ For file uploads or drag-and-drop, use `BlobSource`:
63
+
64
+ ```tsx
65
+ import { Input, ALL_FORMATS, BlobSource } from "mediabunny";
66
+
67
+ export const canDecodeBlob = async (blob: Blob) => {
68
+ const input = new Input({
69
+ formats: ALL_FORMATS,
70
+ source: new BlobSource(blob),
71
+ });
72
+
73
+ // Same validation logic as above
74
+ };
75
+ ```
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: charts
3
+ description: Chart and data visualization patterns for Remotion. Use when creating bar charts, pie charts, histograms, progress bars, or any data-driven animations.
4
+ metadata:
5
+ tags: charts, data, visualization, bar-chart, pie-chart, graphs
6
+ ---
7
+
8
+ # Charts in Remotion
9
+
10
+ You can create bar charts in Remotion by using regular React code - HTML and SVG is allowed, as well as D3.js.
11
+
12
+ ## No animations not powered by `useCurrentFrame()`
13
+
14
+ Disable all animations by third party libraries.
15
+ They will cause flickering during rendering.
16
+ Instead, drive all animations from `useCurrentFrame()`.
17
+
18
+ ## Bar Chart Animations
19
+
20
+ See [Bar Chart Example](assets/charts/bar-chart.tsx) for a basic example implmentation.
21
+
22
+ ### Staggered Bars
23
+
24
+ You can animate the height of the bars and stagger them like this:
25
+
26
+ ```tsx
27
+ const STAGGER_DELAY = 5;
28
+ const frame = useCurrentFrame();
29
+ const {fps} = useVideoConfig();
30
+
31
+ const bars = data.map((item, i) => {
32
+ const delay = i * STAGGER_DELAY;
33
+ const height = spring({
34
+ frame,
35
+ fps,
36
+ delay,
37
+ config: {damping: 200},
38
+ });
39
+ return <div style={{height: height * item.value}} />;
40
+ });
41
+ ```
42
+
43
+ ## Pie Chart Animation
44
+
45
+ Animate segments using stroke-dashoffset, starting from 12 o'clock.
46
+
47
+ ```tsx
48
+ const frame = useCurrentFrame();
49
+ const {fps} = useVideoConfig();
50
+
51
+ const progress = interpolate(frame, [0, 100], [0, 1]);
52
+
53
+ const circumference = 2 * Math.PI * radius;
54
+ const segmentLength = (value / total) * circumference;
55
+ const offset = interpolate(progress, [0, 1], [segmentLength, 0]);
56
+
57
+ <circle r={radius} cx={center} cy={center} fill="none" stroke={color} strokeWidth={strokeWidth} strokeDasharray={`${segmentLength} ${circumference}`} strokeDashoffset={offset} transform={`rotate(-90 ${center} ${center})`} />;
58
+ ```