" tag should be used.
```tsx
import {Audio} from '@remotion/media';
export const MyComp: React.FC = () => {
return ;
};
```
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
import {staticFile} from 'remotion';
import {Audio} from '@remotion/media';
export const MyComp: React.FC = () => {
return ;
};
```
Audio has a "trimBefore" prop that trims the left side of a audio by a number of frames.
Audio has a "trimAfter" prop that limits how long a audio is shown.
Audio has a "volume" prop that sets the volume of the audio. It accepts values between 0 and 1.
If two elements should be rendered on top of each other, they should be layered using the "AbsoluteFill" component from "remotion".
```tsx
import {AbsoluteFill} from 'remotion';
export const MyComp: React.FC = () => {
return (
This is in the back
This is in front
);
};
```
Any Element can be wrapped in a "Sequence" component from "remotion" to place the element later in the video.
```tsx
import {Sequence} from 'remotion';
export const MyComp: React.FC = () => {
return (
This only appears after 10 frames
);
};
```
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.
A Sequence has a "durationInFrames" prop that specifies how long the element should appear.
If a child component of Sequence calls "useCurrentFrame()", the enumeration starts from the first frame the Sequence appears and starts at 0.
```tsx
import {Sequence} from 'remotion';
export const Child: React.FC = () => {
const frame = useCurrentFrame();
return At frame 10, this should be 0: {frame}
;
};
export const MyComp: React.FC = () => {
return (
);
};
```
For displaying multiple elements after another, the "Series" component from "remotion" can be used.
```tsx
import {Series} from 'remotion';
export const MyComp: React.FC = () => {
return (
This only appears immediately
This only appears after 20 frames
This only appears after 42 frames
);
};
```
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
import {
linearTiming,
springTiming,
TransitionSeries,
} from '@remotion/transitions';
import {fade} from '@remotion/transitions/fade';
import {wipe} from '@remotion/transitions/wipe';
export const MyComp: React.FC = () => {
return (
);
};
```
"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.
Remotion needs all of the React code to be deterministic. Therefore, it is forbidden to use the Math.random() API.
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
import {random} from 'remotion';
export const MyComp: React.FC = () => {
return Random number: {random('my-seed')}
;
};
```
Remotion includes an interpolate() helper that can animate values over time.
```tsx
import {interpolate} from 'remotion';
export const MyComp: React.FC = () => {
const frame = useCurrentFrame();
const value = interpolate(frame, [0, 100], [0, 1], {
extrapolateLeft: 'clamp',
extrapolateRight: 'clamp',
});
return (
Frame {frame}: {value}
);
};
```
The "interpolate()" function accepts a number and two arrays of numbers.
The first argument is the value to animate.
The first array is the input range, the second array is the output range.
The fourth argument is optional but code should add "extrapolateLeft: 'clamp'" and "extrapolateRight: 'clamp'" by default.
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
import {useVideoConfig} from 'remotion';
export const MyComp: React.FC = () => {
const {fps, durationInFrames, height, width} = useVideoConfig();
return (
fps: {fps}
durationInFrames: {durationInFrames}
height: {height}
width: {width}
);
};
```
Remotion includes a "spring()" helper for spring-based motion. By default it animates from 0 to 1; the duration is not fixed in advance.
```tsx
import {spring} from 'remotion';
export const MyComp: React.FC = () => {
const frame = useCurrentFrame();
const {fps} = useVideoConfig();
const value = spring({
fps,
frame,
config: {
damping: 200,
},
});
return (
Frame {frame}: {value}
);
};
```
## Rendering
To render a video, the CLI command "npx remotion render [id]" can be used.
The composition "id" should be passed, for example:
$ npx remotion render MyComp
To render a still image, the CLI command "npx remotion still [id]" can be used.
For example:
$ npx remotion still MyComp
## Rendering on Lambda
Videos can be rendered in the cloud using AWS Lambda.
The setup described under https://www.remotion.dev/docs/lambda/setup must be completed.
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/create. 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