Skip to content

🎥 Make videos programmatically with React

brownfield docs

Jonny Burger5e1e983ca317
diff --git a/packages/docs/docs/brownfield-installation.md b/packages/docs/docs/brownfield-installation.md
new file mode 100644
index 0000000000..af82305ace
--- /dev/null
+++ b/packages/docs/docs/brownfield-installation.md
@@ -0,0 +1,192 @@
+---
+id: brownfield
+title: Installing Remotion in an existing project
+sidebar_label: Installation in existing project
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+Remotion can be installed into any Node.JS based project, such as Create React App, Next.JS apps as well as server-only projects such as an Express API. Get started by adding the following packages:
+
+<Tabs
+defaultValue="npm"
+values={[
+{ label: 'npm', value: 'npm', },
+{ label: 'yarn', value: 'yarn', },
+{ label: 'pnpm', value: 'pnpm', },
+]
+}>
+<TabItem value="npm">
+
+```bash
+npm i @remotion/cli remotion
+```
+
+ </TabItem>
+
+ <TabItem value="yarn">
+
+```bash
+yarn add @remotion/cli remotion
+```
+
+ </TabItem>
+
+ <TabItem value="pnpm">
+
+```bash
+pnpm i @remotion/cli remotion
+```
+
+ </TabItem>
+</Tabs>
+
+- If you'd like to embed a Remotion video in your existing React app, install [`@remotion/player`](/docs/player/installation) as well.
+- If you'd like to render a video using the Node.JS APIs, install [`@remotion/renderer`](/docs/renderer) as well.
+- If you'd like to trigger a render on Remotion Lambda, install [`@remotion/lambda`](/docs/lambda/setup) as well.
+
+## Setting up the folder structure
+
+Create a new folder for the Remotion files. It can be anywhere and assume any name, in this example we name it `remotion` and put it in the root of our project. Inside the folder you created, create 3 files:
+
+```tsx twoslash title="remotion/Composition.tsx"
+export const MyComposition = () => {
+ return null;
+};
+```
+
+```tsx twoslash title="remotion/index.ts"
+// @filename: Composition.tsx
+export const MyComposition: React.FC = () => {
+ return null;
+};
+// @filename: Video.tsx
+// ---cut---
+import React from "react";
+import { Composition } from "remotion";
+import { MyComposition } from "./Composition";
+
+export const RemotionVideo: React.FC = () => {
+ return (
+ <>
+ <Composition
+ id="Empty"
+ component={MyComposition}
+ durationInFrames={60}
+ fps={30}
+ width={1280}
+ height={720}
+ />
+ </>
+ );
+};
+```
+
+```ts twoslash title="remotion/index.ts"
+// @filename: Composition.tsx
+export const MyComposition: React.FC = () => {
+ return null;
+};
+// @filename: Video.tsx
+import React from "react";
+import { Composition } from "remotion";
+import { MyComposition } from "./Composition";
+
+export const RemotionVideo: React.FC = () => {
+ return (
+ <>
+ <Composition
+ id="MyComp"
+ component={MyComposition}
+ durationInFrames={60}
+ fps={30}
+ width={1280}
+ height={720}
+ />
+ </>
+ );
+};
+// @filename: index.ts
+// ---cut---
+import { registerRoot } from "remotion";
+import { RemotionVideo } from "./Video";
+
+registerRoot(RemotionVideo);
+```
+
+The file that calls [`registerRoot()`](/docs/register-root) is now your Remotion **entrypoint**.
+
+## Starting the preview
+
+Start the preview server using the following command:
+
+```
+npx remotion preview remotion/index.ts
+```
+
+Replace `remotion/index.ts` with your entrypoint if necessary.
+
+## Render a video
+
+Render our a video using
+
+```
+npx remotion render remotion/index.ts MyComp out.mp4
+```
+
+Replace the entrypoint, composition name and output filename with the values that correspond to your usecase.
+
+## Install the ESLint Plugin
+
+Remotion has an ESLint plugin that warns about improper usage of Remotion APIs. To add it to your existing project, install it:
+
+<Tabs
+defaultValue="npm"
+values={[
+{ label: 'npm', value: 'npm', },
+{ label: 'yarn', value: 'yarn', },
+{ label: 'pnpm', value: 'pnpm', },
+]
+}>
+<TabItem value="npm">
+
+```bash
+npm i @remotion/eslint-plugin
+```
+
+ </TabItem>
+
+ <TabItem value="yarn">
+
+```bash
+yarn add @remotion/eslint-plugin
+```
+
+ </TabItem>
+
+ <TabItem value="pnpm">
+
+```bash
+pnpm i @remotion/eslint-plugin
+```
+
+ </TabItem>
+</Tabs>
+
+This snippet will enable the recommended rules only for the Remotion files:
+
+```json title=".eslintrc"
+{
+ "overrides": [
+ {
+ "files": ["remotion/*.{ts,tsx}"],
+ "extends": ["plugin:@remotion/recommended"]
+ }
+ ]
+}
+```
+
+## Embed a Remotion video into your React app
+
+You can use the `<Player>` component to display a Remotion video in your React project. Read the [separate page](/docs/player/integration) about it for instructions.
diff --git a/packages/docs/docs/getting-started.md b/packages/docs/docs/getting-started.md
index 46cc170a60..4511154def 100644
--- a/packages/docs/docs/getting-started.md
+++ b/packages/docs/docs/getting-started.md
@@ -10,12 +10,12 @@ import TabItem from '@theme/TabItem';
## Prerequisites
-The only dependencies for Remotion are FFMPEG and Node.js.
+The only dependencies for Remotion are Node.JS and FFMPEG.
See:
- [Installing Node.js](https://nodejs.org/en/download/) - Minimum: Version 14.0.0
-- [Installing FFMPEG](https://github.com/adaptlearning/adapt_authoring/wiki/Installing-FFmpeg) - Minimum version: 4.1.0 - you will only need it for rendering.
+- [Installing FFMPEG](https://github.com/adaptlearning/adapt_authoring/wiki/Installing-FFmpeg) - Minimum version: 4.1.0 - only needed if you want to render your video.
## Installation
diff --git a/packages/docs/docs/img.md b/packages/docs/docs/img.md
index cd635720c0..dcf054142a 100644
--- a/packages/docs/docs/img.md
+++ b/packages/docs/docs/img.md
@@ -17,6 +17,10 @@ export const MyComp: React.FC = () => {
};
```
+## GIFs
+
+Don't use the `<Img>` tag for GIFs, use [`@remotion/gif`](/docs/gif) instead.
+
## Restrictions
- The maximum resolution that Chrome can display is `2^29` pixels (539 megapixels) <sup><a href="https://stackoverflow.com/questions/57223559/what-is-the-maximum-image-dimensions-supported-in-desktop-chrome#:~:text=than%202%5E29-,(539MP)">[source]</a></sup>. Remotion inherits this restriction.
diff --git a/packages/docs/docs/lambda/setup.md b/packages/docs/docs/lambda/setup.md
index cbe86cd6cc..6de7588a6c 100644
--- a/packages/docs/docs/lambda/setup.md
+++ b/packages/docs/docs/lambda/setup.md
@@ -11,28 +11,56 @@ import TabItem from '@theme/TabItem';
Check the newest version number in the [#lambda Discord channel](https://discord.gg/PzjkKS8S5S)
+<Tabs
+defaultValue="npm"
+values={[
+{ label: 'npm', value: 'npm', },
+{ label: 'yarn', value: 'yarn', },
+{ label: 'pnpm', value: 'pnpm', },
+]
+}>
+<TabItem value="npm">
+
+```bash
+npm i @remotion/lambda
```
-npm i @remotion/lambda@<version-number>
+
+ </TabItem>
+
+ <TabItem value="yarn">
+
+```bash
+yarn add @remotion/lambda
+```
+
+ </TabItem>
+
+ <TabItem value="pnpm">
+
+```bash
+pnpm i @remotion/lambda
```
-Also update **all the other Remotion packages** to have the same version: `remotion`, `@remotion/cli`, `@remotion/bundler`
+ </TabItem>
+</Tabs>
+
+Also update **all the other Remotion packages** to have the same version: `remotion`, `@remotion/cli` and others.
-:::tip
-Make sure no package version number has a `^` character in front of it as it will install a different version.
+:::note
+Make sure no package version number has a `^` character in front of it as it can lead to a version conflict.
:::
Your package.json should look like the following:
```json
- "@remotion/bundler": "3.0.0",
- "@remotion/cli": "3.0.0",
- "@remotion/lambda": "3.0.0",
+ "@remotion/cli": "3.0.0", // Replace 3.0.0 with the current version
+ "@remotion/lambda": "3.0.0", // Remove any `^` character
// ...
"remotion": "3.0.0",
```
-:::tip
-You can install `@remotion/lambda` in any project, not just a Remotion one, but remember to also install `react` and `react-dom` as they are peer dependencies.
+:::note
+You can install `@remotion/lambda` in any Node.JS project to trigger a render, but remember to also install `react` and `react-dom` as they are peer dependencies.
:::
## 2. Create role policy
diff --git a/packages/docs/docs/player/api.md b/packages/docs/docs/player/api.md
index 2b7e3ceb59..4073a5e4fd 100644
--- a/packages/docs/docs/player/api.md
+++ b/packages/docs/docs/player/api.md
@@ -11,8 +11,8 @@ A React component which takes the following props:
Pass a React component in directly **or** pass a function that returns a dynamic import. Passing neither or both of the props is an error.
-:::info
-The component you pass in should not render the [`<Composition />`](/docs/composition) component, but rather your custom video component instead - the component you would pass into the `component` prop of the [`<Composition />`](/docs/composition) component.
+:::note
+Pass the same React component that you would pass to a `<Composition>`. **Don't** pass in a `<Composition>` or a component returning `<Composition>`
:::
### `durationInFrames`
diff --git a/packages/docs/docs/player/player-integration.md b/packages/docs/docs/player/player-integration.md
index 2f36eb529f..6eea846844 100644
--- a/packages/docs/docs/player/player-integration.md
+++ b/packages/docs/docs/player/player-integration.md
@@ -7,6 +7,10 @@ import Tabs from "@theme/Tabs";
If you are using the player, a common desire is to share the code with your Remotion Preview and/or server-side rendering. With the correct setup, you can write the component once and use it for previewing, displaying and rendering.
+:::note
+Remotion and your React app use a different Webpack config. Therefore, if you want to override your [Webpack configuration](/docs/webpack), you need to override both the Remotion one and the React app one.
+:::
+
## Setup
Set up a React project with your preferred setup, such as [Create React App](https://reactjs.org/docs/create-a-new-react-app.html) or [Next.JS](https://nextjs.org/learn/basics/create-nextjs-app/setup).
@@ -24,7 +28,7 @@ values={[
<TabItem value="npm">
```bash
-npm i remotion @remotion/renderer @remotion/cli @remotion/bundler @remotion/player
+npm i remotion @remotion/cli @remotion/player
```
</TabItem>
@@ -32,14 +36,14 @@ npm i remotion @remotion/renderer @remotion/cli @remotion/bundler @remotion/play
<TabItem value="yarn">
```bash
-yarn add remotion @remotion/renderer @remotion/cli @remotion/bundler @remotion/player
+yarn add remotion @remotion/cli @remotion/player
```
</TabItem>
<TabItem value="pnpm">
```bash
-pnpm i remotion @remotion/renderer @remotion/cli @remotion/bundler @remotion/player
+pnpm i remotion @remotion/cli @remotion/player
```
</TabItem>
@@ -161,15 +165,15 @@ export const App: React.FC = () => {
};
```
-:::tip
-Don't import your composition list or index file into your webapp. It will do nothing.
+:::note
+Pass your React component directly to the `component` prop. Don't pass the list of compositions.
:::
If everything worked, you can now run your webapp and preview your video.
## Creating a bundle for server-side rendering
-In any Node.JS context, you can call [`bundle()`](/docs/bundle) to bundle your video using Webpack and to server-side render the video.
+In any Node.JS context, you can call [`bundle()`](/docs/bundle) to bundle your video using Webpack and to server-side render the video. You need to add `@remotion/bundler` to your package.json for this.
```ts twoslash title="server.tsx"
// @module: ESNext
@@ -186,7 +190,7 @@ const bundled = await bundle(
See [Server-side rendering](/docs/ssr) for a full example.
:::tip
-When using Lambda, you don't need this, you can use the CLI or `deploySite()` which will bundle the video for you.
+When using Lambda, you don't need this, you can use the CLI or [`deploySite()`](/docs/lambda/deploysite) which will bundle the video for you.
:::
## See also
diff --git a/packages/docs/docs/renderer.md b/packages/docs/docs/renderer.md
index f4c72b3bd3..0b9c34ef29 100644
--- a/packages/docs/docs/renderer.md
+++ b/packages/docs/docs/renderer.md
@@ -4,9 +4,53 @@ sidebar_label: Overview
title: "@remotion/renderer"
---
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
The `@remotion/renderer` package provides APIs for rendering video server-side.
The package is also internally used by the Remotion CLI and [Remotion Lambda](/docs/lambda).
+## Installation
+
+<Tabs
+defaultValue="npm"
+values={[
+{ label: 'npm', value: 'npm', },
+{ label: 'yarn', value: 'yarn', },
+{ label: 'pnpm', value: 'pnpm', },
+]
+}>
+<TabItem value="npm">
+
+```bash
+npm i @remotion/renderer
+```
+
+ </TabItem>
+
+ <TabItem value="yarn">
+
+```bash
+yarn add @remotion/renderer
+```
+
+ </TabItem>
+
+ <TabItem value="pnpm">
+
+```bash
+pnpm i @remotion/renderer
+```
+
+ </TabItem>
+</Tabs>
+
+Also update **all the other Remotion packages** to have the same version: `remotion`, `@remotion/cli` and others.
+
+:::note
+Make sure no package version number has a `^` character in front of it as it can lead to a version conflict.
+:::
+
## Server-side rendering examples
See the [Server-side rendering](/docs/ssr) for some examples of how to use server-side rendering.
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index df28dd38ed..e1daf28c88 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -244,7 +244,7 @@ module.exports = {
type: "category",
label: "Miscellaneous",
collapsed: false,
- items: ["chromium-flags", "prereleases", "gpu", "react-18"],
+ items: ["brownfield", "chromium-flags", "prereleases", "gpu", "react-18"],
},
"3-0-migration",
"2-0-migration",