Skip to content

πŸŽ₯ Make videos programmatically with React

update many fundamental docs

Jonny Burger776eb94fa7c8
diff --git a/packages/docs/docs/animating-properties.md b/packages/docs/docs/animating-properties.md
index 0057ef5a79..2534bfaa73 100644
--- a/packages/docs/docs/animating-properties.md
+++ b/packages/docs/docs/animating-properties.md
@@ -39,37 +39,21 @@ export const FadeIn = () => {
## Using the interpolate helper function
-Using the [`interpolate()`](/docs/interpolate) function can make animations more readable.
-The function takes 4 arguments:
+Using the [`interpolate()`](/docs/interpolate) function can make animations more readable. The above animation can also be written as:
-1. The input value
-2. The range values which the input can assume
-3. The range of values that you want to map the input to
-4. Optional settings
-
-```tsx twoslash {6-8, 16}
-import { interpolate, useCurrentFrame } from "remotion";
-
-export const MyVideo = () => {
- const frame = useCurrentFrame();
-
- const opacity = interpolate(frame, [0, 60], [0, 1], {
- extrapolateRight: "clamp",
- });
-
- return (
- <div
- style={{
- flex: 1,
- textAlign: "center",
- fontSize: "7em",
- opacity: opacity,
- }}
- >
- Hello World!
- </div>
- );
-};
+```tsx twoslash
+import { useCurrentFrame } from "remotion";
+const frame = useCurrentFrame();
+// ---cut---
+import { interpolate } from "remotion";
+
+const opacity = interpolate(frame, [0, 60], [0, 1], {
+ /* ^^^^^ ^^^^^ ^^^^
+ Variable to interpolate ----| | |
+ Input range ------------------------| |
+ Output range -------------------------------| */
+ extrapolateRight: "clamp",
+});
```
In this example, we map the frames 0 to 60 to their opacity values `(0, 0.0166, 0.033, 0.05 ...`) and use the [`extrapolateRight`](/docs/interpolate#extrapolateright) setting to clamp the output so that it never becomes bigger than 1.
@@ -113,6 +97,6 @@ The default spring configuration leads to a little bit of overshoot, meaning the
## Always animate using `useCurrentFrame()`
-Watch out for flickering issues during rendering that arise if you write animations that are not driven by [`useCurrentFrame()`](/docs/use-current-frame) - for example CSS transitions.
+Watch out for flickering issues during rendering that arise if you write animations that are not driven by [`useCurrentFrame()`](/docs/use-current-frame) – for example CSS transitions.
[Read more about how Remotion's rendering works](/docs/flickering) - understanding it will help you avoid issues down the road.
diff --git a/packages/docs/docs/cli/render.md b/packages/docs/docs/cli/render.md
index 15838f8db0..10182c0c08 100644
--- a/packages/docs/docs/cli/render.md
+++ b/packages/docs/docs/cli/render.md
@@ -10,7 +10,7 @@ import {AngleChangelog} from '../../components/AngleChangelog';
Render a video or audio based on the entry point, the composition ID and save it to the output location.
```bash
-npx remotion render <entry-file> [<composition-id>] [<output-location>]
+npx remotion render <entry-file?> [<composition-id>] [<output-location>]
```
If `entry-file` is not passed, Remotion will try to detect the entry file with the following priority order:
diff --git a/packages/docs/docs/getting-started.md b/packages/docs/docs/getting-started.md
index 67579fedbe..d162a7835d 100644
--- a/packages/docs/docs/getting-started.md
+++ b/packages/docs/docs/getting-started.md
@@ -1,7 +1,7 @@
---
image: /generated/articles-docs-getting-started.png
id: getting-started
-title: Setup and Installation
+title: Creating a new project
sidebar_label: Installation
slug: /
crumb: "Let's begin!"
@@ -12,9 +12,10 @@ import TabItem from '@theme/TabItem';
## Prerequisites
-To use Remotion, you need at least Node 16. See: [Installing Node.js](https://nodejs.org/en/download/)
+To use Remotion, you need at least Node 16.
+[Install Node.js here.](https://nodejs.org/en/download/)
-## Installation
+## Scaffolding a new project
You can initialize a new Remotion video using
@@ -50,12 +51,21 @@ yarn create video
</TabItem>
</Tabs>
-That's it! Wait for the installation to be finished and follow the instructions in the terminal.
+Choose the template that is most suitable for you. For your first project, we recommend the [Hello World](/templates/hello-world) template.
-### Additional step for Linux users
+After the project has been scaffolded, we recommend to open the project in your text editor and running to start the Remotion Preview:
-Linux users need to install some additional packages to get Chrome/Puppeteer working correctly.
+```bash
+npm start
+```
+
+<details>
+<summary>
+Additional step for Linux users
+
+</summary>
+Linux users need to install some additional packages to get Chrome/Puppeteer working correctly.
<Tabs
defaultValue="arch"
values={[
@@ -87,11 +97,8 @@ Watch out for `apt` wanting to uninstall critical packages (e.g the Desktop) in
Got instructions for more Linux distributions? [Add them to this page](https://github.com/remotion-dev/remotion/edit/main/packages/docs/docs/getting-started.md)!
-## FFmpeg requirement
-
-Remotion requires `ffmpeg` and `ffprobe` binaries (minimum version 4.1) to render videos.
-If you don't have them, [Remotion will try to install FFmpeg for you](/docs/ffmpeg).
+</details>
## Installation in existing projects
-If you already have a project you want to install Remotion in, don't use the instructions on this page. Instead, check out: [Installation in existing projects](/docs/brownfield)
+If you already have a project you want to install Remotion in, see [Installation in existing projects](/docs/brownfield).
diff --git a/packages/docs/docs/render.md b/packages/docs/docs/render.md
index b1ec69afe2..ee33ddb414 100644
--- a/packages/docs/docs/render.md
+++ b/packages/docs/docs/render.md
@@ -5,34 +5,32 @@ title: Render your video
crumb: "How To"
---
-Now here comes the magic! Turn your creation into an MP4.
+Now here comes the magic! To render a video, click the <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style={{height: 16, verticalAlign: "text-bottom"}}><path d="M117.8 128H207C286.9-3.7 409.5-8.5 483.9 5.3c11.6 2.2 20.7 11.2 22.8 22.8c13.8 74.4 9 197-122.7 276.9v89.3c0 25.4-13.4 49-35.3 61.9l-88.5 52.5c-7.4 4.4-16.6 4.5-24.1 .2s-12.1-12.2-12.1-20.9l0-114.7c0-22.6-9-44.3-25-60.3s-37.7-25-60.3-25H24c-8.6 0-16.6-4.6-20.9-12.1s-4.2-16.7 .2-24.1l52.5-88.5c13-21.9 36.5-35.3 61.9-35.3zM424 128a40 40 0 1 0 -80 0 40 40 0 1 0 80 0zM166.5 470C132.3 504.3 66 511 28.3 511.9c-16 .4-28.6-12.2-28.2-28.2C1 446 7.7 379.7 42 345.5c34.4-34.4 90.1-34.4 124.5 0s34.4 90.1 0 124.5zm-46.7-36.4c11.4-11.4 11.4-30 0-41.4s-30-11.4-41.4 0c-10.1 10.1-13 28.5-13.7 41.3c-.5 8 5.9 14.3 13.9 13.9c12.8-.7 31.2-3.7 41.3-13.7z"/></svg> icon in the toolbar.
+Once you are satisfied with the options, confirm the render using the blue `Render video` button.
-```bash
-npm run build
-```
+## More ways to render
-The underlying command in package.json is defined as follows:
+### CLI
+
+Render a video using [`render` CLI command](/docs/cli/render):
```bash
-npx remotion render HelloWorld
+npx remotion render
```
-Modify it to select a different video to render, or change its output location.
-Learn about all the options on the [CLI reference page](/docs/cli).
-
-## More ways to render
+Modify the composition ID to select a different video to render, or add an output path at the end if you want to override the default.
### SSR
Remotion has a full-featured server-side rendering API. Read more about it on the [server-side rendering API](/docs/ssr).
-### GitHub Actions
+### AWS Lambda
-You can also render a [video using a GitHub Action.](/docs/ssr#render-using-github-actions)
+Check out [Remotion Lambda](/docs/lambda).
-### AWS Lambda
+### GitHub Actions
-Check out [**Remotion Lambda**](/docs/lambda).
+You can also render a [video using a GitHub Action.](/docs/ssr#render-using-github-actions)
### Only audio
diff --git a/packages/docs/docs/sequences.md b/packages/docs/docs/sequences.md
index e12ffd4cb2..5bff926bb9 100644
--- a/packages/docs/docs/sequences.md
+++ b/packages/docs/docs/sequences.md
@@ -1,48 +1,55 @@
---
image: /generated/articles-docs-sequences.png
id: reusability
-title: Reuse components using Sequences
+title: Making components reusable
sidebar_label: Reuse components
crumb: "The power of React"
---
```twoslash include example
-import {interpolate, useCurrentFrame} from 'remotion'
+import {interpolate, useCurrentFrame, AbsoluteFill} from 'remotion'
const Title: React.FC<{title: string}> = ({title}) => {
const frame = useCurrentFrame()
const opacity = interpolate(frame, [0, 20], [0, 1], {extrapolateRight: 'clamp'})
return (
- <div style={{opacity}}>{title}</div>
- )
+ <div style={{opacity, textAlign: "center", fontSize: "7em"}}>{title}</div>
+ );
}
// - Title
```
-Let's say we want to show two titles that both fade in after each other.
+React components allow us to encapsulate video logic and reuse the same visuals multiple times.
-In order to make a title reusable, we first factor it out into it's own component.
+Consider a title - to make it reusable, factor it out into its own component:
-```tsx twoslash
-// @include: example-Title
+```tsx twoslash title="MyComposition.tsx"
+import { AbsoluteFill, interpolate, useCurrentFrame } from "remotion";
+
+const Title: React.FC<{ title: string }> = ({ title }) => {
+ const frame = useCurrentFrame();
+ const opacity = interpolate(frame, [0, 20], [0, 1], {
+ extrapolateRight: "clamp",
+ });
+
+ return (
+ <div style={{ opacity, textAlign: "center", fontSize: "7em" }}>{title}</div>
+ );
+};
export const MyVideo = () => {
return (
- <div
- style={{
- flex: 1,
- textAlign: "center",
- fontSize: "7em",
- }}
- >
+ <AbsoluteFill>
<Title title="Hello World" />
- </div>
+ </AbsoluteFill>
);
};
```
-Now we can use the `<Sequence>` component to limit the duration of the first title and time-shift the appearance of the second title.
+To render multiple instances of the title, duplicate the `<Title>` component.
+
+You can also use the `<Sequence>` component to limit the duration of the first title and time-shift the appearance of the second title.
```tsx twoslash
// @include: example-Title
@@ -51,27 +58,23 @@ import { Sequence } from "remotion";
export const MyVideo = () => {
return (
- <div
- style={{
- flex: 1,
- textAlign: "center",
- fontSize: "7em",
- backgroundColor: "white",
- }}
- >
+ <AbsoluteFill>
<Sequence durationInFrames={40}>
<Title title="Hello" />
</Sequence>
<Sequence from={40}>
<Title title="World" />
</Sequence>
- </div>
+ </AbsoluteFill>
);
};
```
-You should see two titles appearing after each other. Sequences which are not shown during a frame are unmounted.
-Sequences by default are absolutely positioned - you can use [`layout="none"`](/docs/sequence#layout) to disable that.
+You should see two titles appearing after each other.
+
+Note that the value of `useCurrentFrame()` has been shifted in the second instance, so that it returns `0` only when the absolute time is `40`. Before that, the sequence was not mounted at all.
+
+Sequences by default are absolutely positioned - you can use [`layout="none"`](/docs/sequence#layout) to make them render like a regular `<div>`.
## See also
diff --git a/packages/docs/docs/ssr.md b/packages/docs/docs/ssr.md
index 5e06a56fb8..212417f5a5 100644
--- a/packages/docs/docs/ssr.md
+++ b/packages/docs/docs/ssr.md
@@ -91,8 +91,8 @@ Note that we only added a minimal example. For production, you should consider a
## Render using GitHub Actions
-The template includes a GitHub Actions workflow file
-under `.github/workflows/render-video.yml`. All you have to do is to adjust the props that your root component accepts in the workflow file and you can render a video right on GitHub.
+The Hello World template includes a GitHub Actions workflow file
+under [`.github/workflows/render-video.yml`](https://github.com/remotion-dev/template-helloworld/blob/main/.github/workflows/render-video.yml). All you have to do is to adjust the props that your root component accepts in the workflow file and you can render a video right on GitHub.
1. Commit the template to a GitHub repository
2. On GitHub, click the 'Actions' tab.
diff --git a/packages/docs/docs/the-fundamentals.md b/packages/docs/docs/the-fundamentals.md
index a76c2da9fe..518477be02 100644
--- a/packages/docs/docs/the-fundamentals.md
+++ b/packages/docs/docs/the-fundamentals.md
@@ -5,8 +5,10 @@ title: The fundamentals
crumb: "Getting started"
---
+## React components
+
```twoslash include example
-import { useCurrentFrame, AbsoluteFill } from "remotion";
+import { AbsoluteFill, useCurrentFrame } from "remotion";
export const MyComposition = () => {
const frame = useCurrentFrame();
@@ -17,7 +19,7 @@ export const MyComposition = () => {
justifyContent: "center",
alignItems: "center",
fontSize: 100,
- backgroundColor: "white"
+ backgroundColor: "white",
}}
>
The current frame is {frame}.
@@ -27,9 +29,9 @@ export const MyComposition = () => {
// - MyComposition
```
-The basic idea behind Remotion is that we'll give you a frame number and a blank canvas, and the freedom to render anything you want using [React](https://reactjs.org).
+The fundamental idea of Remotion is to give you a frame number and a blank canvas, to which you can render anything you want using [React](https://reactjs.org). This is an example React component that renders the current frame as text:
-```tsx twoslash
+```tsx twoslash title="MyComposition.tsx"
// @include: example-MyComposition
```
@@ -41,11 +43,10 @@ A video has 4 properties:
- `width` in pixels.
- `height` in pixels.
-- `durationInFrames`: The number of frames which the video is long.
-- `fps`: Frames per second. The duration in frames divided by FPS results in the duration in seconds.
+- `durationInFrames`: the number of frames which the video is long.
+- `fps`: framerate of the video.
-These properties are variable and you can reuse a component multiple times with different properties.
-Rather than hardcoding these values, we can derive them from the [`useVideoConfig()`](/docs/use-video-config) hook:
+You can obtain these values from the [`useVideoConfig()`](/docs/use-video-config) hook:
```tsx twoslash
import { AbsoluteFill, useVideoConfig } from "remotion";
@@ -68,13 +69,15 @@ export const MyComposition = () => {
};
```
+:::note
A video's first frame is `0` and its last frame is `durationInFrames - 1`.
+:::
-## Defining compositions
+## Compositions
-Using a [composition](/docs/terminology#composition) you can define a video that should be rendered.
+A composition is the combination of a React component and video metadata.
-You define a composition by rendering a [`<Composition>`](/docs/composition) component in `src/Root.tsx`, giving it an `id`, defining values for its `height`, `width`, `fps` and `durationInFrames`, and passing a React component to `component`.
+By rendering a [`<Composition>`](/docs/composition) component in `src/Root.tsx`, you can register a renderable video and make it visible in the Remotion sidebar.
```tsx twoslash title="src/Root.tsx"
import { Composition } from "remotion";
@@ -83,18 +86,19 @@ import { Composition } from "remotion";
export const RemotionRoot: React.FC = () => {
return (
- <>
- <Composition
- id="MyComposition"
- durationInFrames={150}
- fps={30}
- width={1920}
- height={1080}
- component={MyComposition}
- />
- </>
+ <Composition
+ id="MyComposition"
+ durationInFrames={150}
+ fps={30}
+ width={1920}
+ height={1080}
+ component={MyComposition}
+ />
);
};
```
-You can render as many compositions as you like in `src/Root.tsx`.
+:::note
+You can register multiple compositions in `src/Root.tsx` by wrapping them in a React Fragment:
+`<><Composition/><Composition/></>`
+:::
diff --git a/packages/docs/docs/timeline.md b/packages/docs/docs/timeline.md
index ea632ed54b..cea4375047 100644
--- a/packages/docs/docs/timeline.md
+++ b/packages/docs/docs/timeline.md
@@ -5,20 +5,21 @@ id: timeline
crumb: "Timeline basics"
---
-You can start the preview server of Remotion using
+You can start the preview server of Remotion using:
-```sh
+```bash
npm start
```
-This is a shorthand for
+This is a shorthand for the `preview` command of the [Remotion CLI](/docs/cli):
```bash
npx remotion preview
```
-A server will be started on port 3000 (or 3001 if it's not available, and so on) and the preview should open in the browser.
+A server will be started on port `3000` (or a higher port if it's not available) and the preview should open in the browser.
+// TODO: Update the screenshot
<img src="/img/timeline.png"></img>
## Preview controls
@@ -45,15 +46,25 @@ By default, the background of your video is a checkerboard pattern signifying th
## In / Out Markers
-Use the <svg viewBox="0 0 256 256" fill="none" style={{width: 16, height: 16}}><path d="M158 25H99V230.5H158" stroke="currentcolor" strokeWidth="42" strokeLinecap="round" strokeLinejoin="round"/></svg> and <svg viewBox="0 0 256 256" fill="none" style={{width: 16, height: 16}}><path d="M98 25H157V230.5H98" stroke="currentcolor" strokeWidth="42" strokeLinecap="round" strokeLinejoin="round"/></svg> buttons to set an In or Out marker. When you play the video again, only the range within the markers will play.
+Use the <svg viewBox="0 0 256 256" fill="none" style={{width: 16, height: 16}}><path d="M158 25H99V230.5H158" stroke="currentcolor" strokeWidth="42" strokeLinecap="round" strokeLinejoin="round"/></svg> and <svg viewBox="0 0 256 256" fill="none" style={{width: 16, height: 16}}><path d="M98 25H157V230.5H98" stroke="currentcolor" strokeWidth="42" strokeLinecap="round" strokeLinejoin="round"/></svg> buttons to set an In or Out marker. When you play the video again, only the range within the markers will play.
+To clear a marker, make sure your playback head is at the point of a marker and press the button you pressed to activate it again.
-You may also set markers using the <kbd>I</kbd> and <kbd>O</kbd> keys.
+You may also use the keyboard shortcuts:
-To clear a marker, make sure your playback head is at the point of a marker and press the button you pressed to activate it again. Or use the <kbd>X</kbd> key to clear both markers.
+- <kbd>I</kbd>: Set an in marker
+- <kbd>O</kbd> (the letter "O"): Set an out marker
+- <kbd>X</kbd>: Clear both markers.
## Change the canvas size
-The default scaling mode is "Fit", which will scale the video so it fits in the preview window. Use the left dropdown to choose a different scale.
+By default the video scales to fit in the preview window.
+You can pinch:
+
+- pinch to zoom
+- hold <kbd>Shift</kbd> and use the scrollwheel or
+- use the dropdown that says `Fit`
+
+to change the size of the canvas.
## Change the playback speed
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index 8e68ca9814..4f1709a058 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -83,6 +83,7 @@ module.exports = {
"series",
"folder",
"easing",
+ "z",
"null",
"clipper",
],
@@ -336,7 +337,6 @@ module.exports = {
items: [
"getting-started",
"the-fundamentals",
- "transforms",
"animating-properties",
"reusability",
"timeline",
@@ -347,6 +347,7 @@ module.exports = {
type: "category",
label: "Techniques",
items: [
+ "transforms",
"assets",
"using-audio",
"fonts",