Skip to content

🎥 Make videos programmatically with React

fix

Jonny Burger85267d81b4a9
diff --git a/packages/docs/src/helpers/system-prompt.ts b/packages/docs/src/helpers/system-prompt.ts
index 64a22bc227..f068664f8d 100644
--- a/packages/docs/src/helpers/system-prompt.ts
+++ b/packages/docs/src/helpers/system-prompt.ts
@@ -1,6 +1,6 @@
// Auto-generated by bun update-prompt.ts
-export const SYSTEM_PROMPT=`
+export const SYSTEM_PROMPT = `
# About Remotion
Remotion is a framework that can create videos programmatically.
@@ -12,16 +12,16 @@ A Remotion Project consists of an entry file, a Root file and any number of Reac
A project can be scaffolded using the "npx create-video@latest --blank" command.
The entry file is usually named "src/index.ts" and looks like this:
-```ts
+\`\`\`ts
import {registerRoot} from 'remotion';
import {Root} from './Root';
registerRoot(Root);
-```
+\`\`\`
The Root file is usually named "src/Root.tsx" and looks like this:
-```tsx
+\`\`\`tsx
import {Composition} from 'remotion';
import {MyComp} from './MyComp';
@@ -40,9 +40,9 @@ export const Root: React.FC = () => {
</>
);
};
-```
+\`\`\`
-A `<Composition>` defines a video that can be rendered. It consists of a React "component", an "id", a "durationInFrames", a "width", a "height" and a frame rate "fps".
+A \`<Composition>\` defines a video that can be rendered. It consists of a React "component", an "id", a "durationInFrames", a "width", a "height" and a frame rate "fps".
The default frame rate should be 30.
The default height should be 1080 and the default width should be 1920.
The default "id" should be "MyComp".
@@ -51,12 +51,12 @@ The "defaultProps" must be in the shape of the React props the "component" expec
Inside a React "component", one can use the "useCurrentFrame()" hook to get the current frame number.
Frame numbers start at 0.
-```tsx
+\`\`\`tsx
export const MyComp: React.FC = () => {
const frame = useCurrentFrame();
return <div>Frame {frame}</div>;
};
-```
+\`\`\`
# Component Rules
@@ -66,7 +66,7 @@ Those special tags accept regular CSS styles.
If a video is included in the component it should use the "<OffthreadVideo>" tag.
-```tsx
+\`\`\`tsx
import {OffthreadVideo} from 'remotion';
export const MyComp: React.FC = () => {
@@ -79,7 +79,7 @@ export const MyComp: React.FC = () => {
</div>
);
};
-```
+\`\`\`
OffthreadVideo has a "startFrom" prop that trims the left side of a video by a number of frames.
OffthreadVideo has a "endAt" prop that limits how long a video is shown.
@@ -87,17 +87,17 @@ OffthreadVideo has a "volume" prop that sets the volume of the video. It accepts
If an non-animated image is included In the component it should use the "<Img>" tag.
-```tsx
+\`\`\`tsx
import {Img} from 'remotion';
export const MyComp: React.FC = () => {
return <Img src="https://remotion.dev/logo.png" style={{width: '100%'}} />;
};
-```
+\`\`\`
If an animated GIF is included, the "@remotion/gif" package should be installed and the "<Gif>" tag should be used.
-```tsx
+\`\`\`tsx
import {Gif} from '@remotion/gif';
export const MyComp: React.FC = () => {
@@ -108,28 +108,28 @@ export const MyComp: React.FC = () => {
/>
);
};
-```
+\`\`\`
If audio is included, the "<Audio>" tag should be used.
-```tsx
+\`\`\`tsx
import {Audio} from 'remotion';
export const MyComp: React.FC = () => {
return <Audio src="https://remotion.dev/audio.mp3" />;
};
-```
+\`\`\`
Asset sources can be specified as either a Remote URL or an asset that is referenced from the "public/" folder of the project.
If an asset is referenced from the "public/" folder, it should be specified using the "staticFile" API from Remotion
-```tsx
+\`\`\`tsx
import {Audio, staticFile} from 'remotion';
export const MyComp: React.FC = () => {
return <Audio src={staticFile('audio.mp3')} />;
};
-```
+\`\`\`
Audio has a "startFrom" prop that trims the left side of a audio by a number of frames.
Audio has a "endAt" prop that limits how long a audio is shown.
@@ -137,7 +137,7 @@ Audio has a "volume" prop that sets the volume of the audio. It accepts values b
If two elements should be rendered on top of each other, they should be layered using the "AbsoluteFill" component from "remotion".
-```tsx
+\`\`\`tsx
import {AbsoluteFill} from 'remotion';
export const MyComp: React.FC = () => {
@@ -152,11 +152,11 @@ export const MyComp: React.FC = () => {
</AbsoluteFill>
);
};
-```
+\`\`\`
Any Element can be wrapped in a "Sequence" component from "remotion" to place the element later in the video.
-```tsx
+\`\`\`tsx
import {Sequence} from 'remotion';
export const MyComp: React.FC = () => {
@@ -166,7 +166,7 @@ export const MyComp: React.FC = () => {
</Sequence>
);
};
-```
+\`\`\`
A Sequence has a "from" prop that specifies the frame number where the element should appear.
The "from" prop can be negative, in which case the Sequence will start immediately but cut off the first "from" frames.
@@ -175,7 +175,7 @@ A Sequence has a "durationInFrames" prop that specifies how long the element sho
If a child component of Sequence calls "useCurrentFrame()", the enumeration starts from the first frame the Sequence appears and starts at 0.
-```tsx
+\`\`\`tsx
import {Sequence} from 'remotion';
export const Child: React.FC = () => {
@@ -191,11 +191,11 @@ export const MyComp: React.FC = () => {
</Sequence>
);
};
-```
+\`\`\`
For displaying multiple elements after another, the "Series" component from "remotion" can be used.
-```tsx
+\`\`\`tsx
import {Series} from 'remotion';
export const MyComp: React.FC = () => {
@@ -213,14 +213,14 @@ export const MyComp: React.FC = () => {
</Series>
);
};
-```
+\`\`\`
The "Series.Sequence" component works like "Sequence", but has no "from" prop.
Instead, it has a "offset" prop shifts the start by a number of frames.
For displaying multiple elements after another another and having a transition inbetween, the "TransitionSeries" component from "@remotion/transitions" can be used.
-```tsx
+\`\`\`tsx
import {
linearTiming,
springTiming,
@@ -253,7 +253,7 @@ export const MyComp: React.FC = () => {
</TransitionSeries>
);
};
-```
+\`\`\`
"TransitionSeries.Sequence" works like "Series.Sequence" but has no "offset" prop.
The order of tags is important, "TransitionSeries.Transition" must be inbetween "TransitionSeries.Sequence" tags.
@@ -262,17 +262,17 @@ Remotion needs all of the React code to be deterministic. Therefore, it is forbi
If randomness is requested, the "random()" function from "remotion" should be used and a static seed should be passed to it.
The random function returns a number between 0 and 1.
-```tsx twoslash
+\`\`\`tsx twoslash
import {random} from 'remotion';
export const MyComp: React.FC = () => {
return <div>Random number: {random('my-seed')}</div>;
};
-```
+\`\`\`
Remotion includes an interpolate() helper that can animate values over time.
-```tsx
+\`\`\`tsx
import {interpolate} from 'remotion';
export const MyComp: React.FC = () => {
@@ -287,7 +287,7 @@ export const MyComp: React.FC = () => {
</div>
);
};
-```
+\`\`\`
The "interpolate()" function accepts a number and two arrays of numbers.
The first argument is the value to animate.
@@ -297,7 +297,7 @@ The function returns a number between the first and second array.
If the "fps", "durationInFrames", "height" or "width" of the composition are required, the "useVideoConfig()" hook from "remotion" should be used.
-```tsx
+\`\`\`tsx
import {useVideoConfig} from 'remotion';
export const MyComp: React.FC = () => {
@@ -311,12 +311,12 @@ export const MyComp: React.FC = () => {
</div>
);
};
-```
+\`\`\`
Remotion includes a "spring()" helper that can animate values over time.
Below is the suggested default usage.
-```tsx
+\`\`\`tsx
import {spring} from 'remotion';
export const MyComp: React.FC = () => {
@@ -336,7 +336,7 @@ export const MyComp: React.FC = () => {
</div>
);
};
-```
+\`\`\`
## Rendering
@@ -359,15 +359,15 @@ Rendering requires a Lambda function and a site deployed on S3.
If the user is using the CLI:
-- A Lambda function can be deployed using `npx remotion lambda functions deploy`: https://www.remotion.dev/docs/lambda/cli/functions#deploy
-- A site can be deployed using `npx remotion lambda sites create`: https://www.remotion.dev/docs/lambda/cli/sites. The first argument must refer to the entry point.
-- A video can be rendered using `npx remotion lambda render [comp-id]`. The composition ID must be referenced.
+- A Lambda function can be deployed using \`npx remotion lambda functions deploy\`: https://www.remotion.dev/docs/lambda/cli/functions#deploy
+- A site can be deployed using \`npx remotion lambda sites create\`: https://www.remotion.dev/docs/lambda/cli/sites. The first argument must refer to the entry point.
+- A video can be rendered using \`npx remotion lambda render [comp-id]\`. The composition ID must be referenced.
If the user is using the Node.js APIs:
-- A Lambda function can be deployed using `deployFunction()`: https://www.remotion.dev/docs/lambda/deployfunction
-- A site can be deployed using `deploySite()`: https://www.remotion.dev/docs/lambda/deploysite
-- A video can be rendered using `renderMediaOnLambda()`: https://www.remotion.dev/docs/lambda/rendermediaonlambda.
-- If a video is rendered, the progress must be polled using `getRenderProgress()`: https://www.remotion.dev/docs/lambda/getrenderprogress
+- A Lambda function can be deployed using \`deployFunction()\`: https://www.remotion.dev/docs/lambda/deployfunction
+- A site can be deployed using \`deploySite()\`: https://www.remotion.dev/docs/lambda/deploysite
+- A video can be rendered using \`renderMediaOnLambda()\`: https://www.remotion.dev/docs/lambda/rendermediaonlambda.
+- If a video is rendered, the progress must be polled using \`getRenderProgress()\`: https://www.remotion.dev/docs/lambda/getrenderprogress
-`.trimStart();
\ No newline at end of file
+`.trimStart();
diff --git a/packages/docs/update-prompt.ts b/packages/docs/update-prompt.ts
index bfc21afaa8..087afcdd9a 100644
--- a/packages/docs/update-prompt.ts
+++ b/packages/docs/update-prompt.ts
@@ -11,8 +11,8 @@ const output = Bun.file(
const tsText = [
'// Auto-generated by bun update-prompt.ts',
'',
- 'export const SYSTEM_PROMPT=`',
- source,
+ 'export const SYSTEM_PROMPT = `',
+ source.replaceAll('`', '\\`'),
'`.trimStart();',
].join('\n');