Skip to content

🎥 Make videos programmatically with React

nice

Jonny Burger06269af554e8
diff --git a/packages/docs/components/Installation.tsx b/packages/docs/components/Installation.tsx
index 5a646f8587..47072d7509 100644
--- a/packages/docs/components/Installation.tsx
+++ b/packages/docs/components/Installation.tsx
@@ -3,36 +3,79 @@ import React from "react";
import CodeBlock from "@theme/CodeBlock";
import TabItem from "@theme/TabItem";
import Tabs from "@theme/Tabs";
+import { VERSION } from "remotion";
-export const Installation: React.FC = () => {
+const LightAndDark: React.FC<{
+ text: string;
+}> = ({ text }) => {
return (
- <Tabs
- defaultValue="npm"
- values={[
- { label: "npm", value: "npm" },
- { label: "yarn", value: "yarn" },
- { label: "pnpm", value: "pnpm" },
- ]}
- >
- <TabItem value="npm">
- <CodeBlock
- className="shiki github-light"
- language="bash"
- title="hi"
- showLineNumbers
- >
- <div className="code-container">
- <div className="line">{"npm i remotion @remotion/player"}</div>
- </div>
- </CodeBlock>
- </TabItem>
+ <>
+ <CodeBlock
+ className="shiki github-light"
+ language="bash"
+ style={{
+ backgroundColor: "rgb(255, 255, 255)",
+ color: "rgb(36, 41, 47)",
+ }}
+ >
+ <div className="code-container">
+ <div className="line">{text}</div>
+ </div>
+ </CodeBlock>
+ <CodeBlock
+ className="shiki github-dark"
+ language="bash"
+ style={{
+ backgroundColor: "rgb(13, 17, 23)",
+ color: "rgb(201, 209, 217)",
+ }}
+ >
+ <div className="code-container">
+ <div className="line">{text}</div>
+ </div>
+ </CodeBlock>
+ </>
+ );
+};
- <TabItem value="pnpm">
- <code>pnpm i remotion @remotion/player</code>
- </TabItem>
- <TabItem value="yarn">
- <code>yarn add remotion @remotion/player</code>
- </TabItem>
- </Tabs>
+export const Installation: React.FC<{
+ pkg: string;
+}> = ({ pkg }) => {
+ if (pkg === undefined) {
+ throw new Error("pkg is undefined");
+ }
+
+ return (
+ <div>
+ <Tabs
+ defaultValue="npm"
+ values={[
+ { label: "npm", value: "npm" },
+ { label: "yarn", value: "yarn" },
+ { label: "pnpm", value: "pnpm" },
+ { label: "bun", value: "bun" },
+ ]}
+ >
+ <TabItem value="npm">
+ <LightAndDark text={`npm i --save-exact ${pkg}@${VERSION}`} />
+ </TabItem>
+ <TabItem value="pnpm">
+ <LightAndDark text={`pnpm i ${pkg}@${VERSION}`} />
+ </TabItem>
+ <TabItem value="bun">
+ <LightAndDark text={`bun i ${pkg}@${VERSION}`} />
+ </TabItem>
+ <TabItem value="yarn">
+ <LightAndDark text={`yarn --exact add ${pkg}@${VERSION}`} />
+ </TabItem>
+ </Tabs>
+ This assumes you are currently using v{VERSION} of Remotion.
+ <br />
+ Also update <code>remotion</code> and all <code>`@remotion/*`</code>{" "}
+ packages to the same version.
+ <br />
+ Remove all <code>^</code> character in front of the version numbers of it
+ as it can lead to a version conflict.
+ </div>
);
};
diff --git a/packages/docs/docs/bundler.md b/packages/docs/docs/bundler.md
index 1253a4ad94..6cb0b5abce 100644
--- a/packages/docs/docs/bundler.md
+++ b/packages/docs/docs/bundler.md
@@ -9,41 +9,7 @@ A package containing the [`bundle()`](/docs/bundle) function, which takes a Remo
## Installation
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
-
-<Tabs
-defaultValue="npm"
-values={[
-{ label: 'npm', value: 'npm', },
-{ label: 'pnpm', value: 'pnpm', },
-{ label: 'yarn', value: 'yarn', },
-]
-}>
-<TabItem value="npm">
-
-```bash
-npm i @remotion/bundler
-```
-
- </TabItem>
-
- <TabItem value="pnpm">
-
-```bash
-pnpm i @remotion/bundler
-```
-
- </TabItem>
-
- <TabItem value="yarn">
-
-```bash
-yarn add @remotion/bundler
-```
-
- </TabItem>
-</Tabs>
+<Installation pkg="@remotion/bundler"/>
## API
diff --git a/packages/docs/docs/cloudrun-alpha.md b/packages/docs/docs/cloudrun-alpha.md
index e848c24263..19f63a3379 100644
--- a/packages/docs/docs/cloudrun-alpha.md
+++ b/packages/docs/docs/cloudrun-alpha.md
@@ -24,53 +24,7 @@ We are welcoming any [bug reports](https://remotion.dev/issue).
## 1. Install `@remotion/cloudrun`
-<Tabs
-defaultValue="npm"
-values={[
-{ label: 'npm', value: 'npm', },
-{ label: 'yarn', value: 'yarn', },
-{ label: 'pnpm', value: 'pnpm', },
-]
-}>
-<TabItem value="npm">
-
-```bash
-npm i @remotion/cloudrun
-```
-
- </TabItem>
-
- <TabItem value="pnpm">
-
-```bash
-pnpm i @remotion/cloudrun
-```
-
- </TabItem>
- <TabItem value="yarn">
-
-```bash
-yarn add @remotion/cloudrun
-```
-
- </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.
-:::
-
-Your package.json should look like the following:
-
-```json
- "@remotion/cli": "4.0.0", // Replace 4.0.0 with the current version
- "@remotion/cloudrun": "4.0.0", // Remove any `^` character
- // ...
- "remotion": "4.0.0",
-```
+<Installation pkg="@remotion/cloudrun"/>
From `v4.0.18`, Cloud run is distributed together with the main release of Remotion. Before that, you had to install the alpha release (see below).
diff --git a/packages/docs/docs/cloudrun/api.md b/packages/docs/docs/cloudrun/api.md
index 9639bb5ebe..5d2ef8881a 100644
--- a/packages/docs/docs/cloudrun/api.md
+++ b/packages/docs/docs/cloudrun/api.md
@@ -8,48 +8,10 @@ crumb: "Render videos without servers on GCP"
<p>Cloud Run is in <a href="/docs/cloudrun-alpha">Alpha</a>, which means APIs may change in any version and documentation is not yet finished. See the <a href="https://remotion.dev/changelog">changelog to stay up to date with breaking changes</a>.</p>
</ExperimentalBadge>
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
import {TableOfContents} from '../../components/TableOfContents/cloudrun';
-<Tabs
-defaultValue="npm"
-values={[
-{ label: 'npm', value: 'npm', },
-{ label: 'yarn', value: 'yarn', },
-{ label: 'pnpm', value: 'pnpm', },
-]
-}>
-<TabItem value="npm">
-
-```bash
-npm i @remotion/cloudrun
-```
-
- </TabItem>
-
- <TabItem value="pnpm">
-
-```bash
-pnpm i @remotion/cloudrun
-```
-
- </TabItem>
- <TabItem value="yarn">
-
-```bash
-yarn add @remotion/cloudrun
-```
-
- </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.
-:::
+<Installation pkg="@remotion/cloudrun"/>
+<br/>
**See the [setup guide](/docs/cloudrun/setup) for complete instructions on how to get started.**
diff --git a/packages/docs/docs/cloudrun/setup.md b/packages/docs/docs/cloudrun/setup.md
index dec09ad0d9..46451bcad2 100644
--- a/packages/docs/docs/cloudrun/setup.md
+++ b/packages/docs/docs/cloudrun/setup.md
@@ -15,53 +15,7 @@ import TabItem from '@theme/TabItem';
## 1. Install `@remotion/cloudrun`
-<Tabs
-defaultValue="npm"
-values={[
-{ label: 'npm', value: 'npm', },
-{ label: 'yarn', value: 'yarn', },
-{ label: 'pnpm', value: 'pnpm', },
-]
-}>
-<TabItem value="npm">
-
-```bash
-npm i @remotion/cloudrun
-```
-
- </TabItem>
-
- <TabItem value="pnpm">
-
-```bash
-pnpm i @remotion/cloudrun
-```
-
- </TabItem>
- <TabItem value="yarn">
-
-```bash
-yarn add @remotion/cloudrun
-```
-
- </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.
-:::
-
-Your package.json should look like the following:
-
-```json
- "@remotion/cli": "4.0.0", // Replace 4.0.0 with the current version
- "@remotion/cloudrun": "4.0.0", // Remove any `^` character
- // ...
- "remotion": "4.0.0",
-```
+<Installation pkg="@remotion/cloudrun"/>
## 2. Create a GCP project
diff --git a/packages/docs/docs/gif/index.md b/packages/docs/docs/gif/index.md
index 1192aef6a1..b03c6ae933 100644
--- a/packages/docs/docs/gif/index.md
+++ b/packages/docs/docs/gif/index.md
@@ -4,50 +4,11 @@ sidebar_label: "@remotion/gif"
title: "@remotion/gif"
---
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
import {TableOfContents} from '../../components/TableOfContents/gif';
You can install this package from NPM to get a component for displaying GIFs that synchronize with Remotions [`useCurrentFrame()`](/docs/use-current-frame).
-<Tabs
-defaultValue="npm"
-values={[
-{ label: 'npm', value: 'npm', },
-{ label: 'yarn', value: 'yarn', },
-{ label: 'pnpm', value: 'pnpm', },
-]
-}>
-<TabItem value="npm">
-
-```bash
-npm i @remotion/gif
-```
-
- </TabItem>
-
- <TabItem value="pnpm">
-
-```bash
-pnpm i @remotion/gif
-```
-
- </TabItem>
-
- <TabItem value="yarn">
-
-```bash
-yarn add @remotion/gif
-```
-
- </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.
-:::
+<Installation pkg="@remotion/gif"/>
## APIs
diff --git a/packages/docs/docs/lambda/api.md b/packages/docs/docs/lambda/api.md
index 73560b14ad..ff5b32348b 100644
--- a/packages/docs/docs/lambda/api.md
+++ b/packages/docs/docs/lambda/api.md
@@ -4,48 +4,10 @@ title: "@remotion/lambda"
crumb: "Render videos without servers on AWS"
---
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
import {TableOfContents} from '../../components/TableOfContents/lambda';
-<Tabs
-defaultValue="npm"
-values={[
-{ label: 'npm', value: 'npm', },
-{ label: 'yarn', value: 'yarn', },
-{ label: 'pnpm', value: 'pnpm', },
-]
-}>
-<TabItem value="npm">
-
-```bash
-npm i @remotion/lambda
-```
-
- </TabItem>
-
- <TabItem value="pnpm">
-
-```bash
-pnpm i @remotion/lambda
-```
-
- </TabItem>
- <TabItem value="yarn">
-
-```bash
-yarn add @remotion/lambda
-```
-
- </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.
-:::
+<Installation pkg="@remotion/lambda"/>
+<br/>
**See the [setup guide](/docs/lambda/setup) for complete instructions on how to get started.**
diff --git a/packages/docs/docs/lambda/setup.md b/packages/docs/docs/lambda/setup.md
index 84591f512b..0f52738b12 100644
--- a/packages/docs/docs/lambda/setup.md
+++ b/packages/docs/docs/lambda/setup.md
@@ -18,55 +18,7 @@ import TabItem from '@theme/TabItem';
## 1. Install `@remotion/lambda`
-<Tabs
-defaultValue="npm"
-values={[
-{ label: 'npm', value: 'npm', },
-{ label: 'yarn', value: 'yarn', },
-{ label: 'pnpm', value: 'pnpm', },
-]
-}>
-<TabItem value="npm">
-
-```bash
-npm i @remotion/lambda
-```
-
- </TabItem>
-
- <TabItem value="pnpm">
-
-```bash
-pnpm i @remotion/lambda
-```
-
- </TabItem>
- <TabItem value="yarn">
-
-```bash
-yarn add @remotion/lambda
-```
-
- </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.
-:::
-
-Your package.json should look like the following:
-
-```json
- "@remotion/cli": "3.0.0", // Replace 3.0.0 with the current version; install as a dev dependency
- "@remotion/lambda": "3.0.0", // Remove any `^` character
- // ...
- "remotion": "3.0.0",
-```
-
-If any of the above is missing, add them to the `package.json` file and then run `npm install`, `yarn install` or `pnpm install`.
+<Installation pkg="@remotion/lambda"/>
## 2. Create role policy
diff --git a/packages/docs/docs/media-utils/index.md b/packages/docs/docs/media-utils/index.md
index a7c591a371..4d8fc5a9e2 100644
--- a/packages/docs/docs/media-utils/index.md
+++ b/packages/docs/docs/media-utils/index.md
@@ -9,41 +9,7 @@ A package providing utility functions for getting information about video and au
Except for [`useAudioData()`](/docs/use-audio-data), all functions can also be used outside of Remotion.
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
-
-<Tabs
-defaultValue="npm"
-values={[
-{ label: 'npm', value: 'npm', },
-{ label: 'pnpm', value: 'pnpm', },
-{ label: 'yarn', value: 'yarn', },
-]
-}>
-<TabItem value="npm">
-
-```bash
-npm i @remotion/media-utils
-```
-
- </TabItem>
-
- <TabItem value="pnpm">
-
-```bash
-pnpm i @remotion/media-utils
-```
-
- </TabItem>
-
- <TabItem value="yarn">
-
-```bash
-yarn add @remotion/media-utils
-```
-
- </TabItem>
-</Tabs>
+<Installation pkg="@remotion/media-utils"/>
## Functions
diff --git a/packages/docs/docs/motion-blur/index.md b/packages/docs/docs/motion-blur/index.md
index b584512125..de2e43a9c8 100644
--- a/packages/docs/docs/motion-blur/index.md
+++ b/packages/docs/docs/motion-blur/index.md
@@ -7,42 +7,9 @@ _Available from v3.2.31_
Higher order components that create a motion blur and trail effects.
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
import {TableOfContents} from '../../components/TableOfContents/motion-blur';
-<Tabs
-defaultValue="npm"
-values={[
-{ label: 'npm', value: 'npm', },
-{ label: 'pnpm', value: 'pnpm', },
-{ label: 'yarn', value: 'yarn', },
-]
-}>
-<TabItem value="npm">
-
-```bash
-npm i @remotion/motion-blur
-```
-
- </TabItem>
-
- <TabItem value="pnpm">
-
-```bash
-pnpm i @remotion/motion-blur
-```
-
- </TabItem>
-
- <TabItem value="yarn">
-
-```bash
-yarn add @remotion/motion-blur
-```
-
- </TabItem>
-</Tabs>
+<Installation pkg="@remotion/renderer"/>
## Components
diff --git a/packages/docs/docs/player/installation.md b/packages/docs/docs/player/installation.md
index 7c5ae8f124..cf48309c35 100644
--- a/packages/docs/docs/player/installation.md
+++ b/packages/docs/docs/player/installation.md
@@ -10,13 +10,7 @@ import {TableOfContents, PlayerGuide} from '../../components/TableOfContents/pla
To install the Player, run the following command in a React project:
-<Installation />
-
-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.
-:::
+<Installation pkg="@remotion/player"/>
## Components
diff --git a/packages/docs/docs/preload/preload.md b/packages/docs/docs/preload/preload.md
index 982f63c25d..e5d295ec1f 100644
--- a/packages/docs/docs/preload/preload.md
+++ b/packages/docs/docs/preload/preload.md
@@ -17,41 +17,4 @@ An alternative to `@remotion/preload` is the [`prefetch()`](/docs/prefetch) API.
## Installation
-<Tabs
-defaultValue="npm"
-values={[
-{ label: 'npm', value: 'npm', },
-{ label: 'yarn', value: 'yarn', },
-{ label: 'pnpm', value: 'pnpm', },
-]
-}>
-<TabItem value="npm">
-
-```bash
-npm i @remotion/preload
-```
-
- </TabItem>
-
- <TabItem value="pnpm">
-
-```bash
-pnpm i @remotion/preload
-```
-
- </TabItem>
- <TabItem value="yarn">
-
-```bash
-yarn add @remotion/preload
-```
-
- </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.
-:::
+<Installation pkg="@remotion/preload"/>
diff --git a/packages/docs/docs/renderer.md b/packages/docs/docs/renderer.md
index ea21202cec..6bb65bd488 100644
--- a/packages/docs/docs/renderer.md
+++ b/packages/docs/docs/renderer.md
@@ -5,8 +5,6 @@ sidebar_label: Overview
title: "@remotion/renderer"
---
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
import {TableOfContents} from '../components/TableOfContents/renderer';
The `@remotion/renderer` package provides APIs for rendering video server-side.
@@ -18,44 +16,7 @@ The configuration file has no effect when using these APIs.
## 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="pnpm">
-
-```bash
-pnpm i @remotion/renderer
-```
-
- </TabItem>
-
- <TabItem value="yarn">
-
-```bash
-yarn add @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.
-:::
+<Installation pkg="@remotion/renderer"/>
## Server-side rendering examples
diff --git a/packages/docs/docs/tailwind/overview.md b/packages/docs/docs/tailwind/overview.md
index 14eadc7e4d..3435bfb5d0 100644
--- a/packages/docs/docs/tailwind/overview.md
+++ b/packages/docs/docs/tailwind/overview.md
@@ -15,44 +15,9 @@ This package provides utilities useful for integrating [TailwindCSS](https://tai
Install `@remotion/tailwind` as well as TailwindCSS dependencies.
-<Tabs
-defaultValue="npm"
-values={[
-{ label: 'npm', value: 'npm', },
-{ label: 'yarn', value: 'yarn', },
-{ label: 'pnpm', value: 'pnpm', },
-]
-}>
-<TabItem value="npm">
-
-```bash
-npm i -D @remotion/tailwind
-```
-
- </TabItem>
-
- <TabItem value="yarn">
-
-```bash
-yarn add -D @remotion/tailwind
-```
-
- </TabItem>
-
- <TabItem value="pnpm">
-
-```bash
-pnpm i -D @remotion/tailwind
-```
-
- </TabItem>
-</Tabs>
-
-Also update **all the other Remotion packages** to have the same version: `remotion`, `@remotion/cli` and others.
+<Installation pkg="@remotion/renderer"/>
-:::note
-Make sure no package version number has a `^` character in front of it as it can lead to a version conflict.
-:::
+<br/>
[Override the Webpack config](/docs/webpack) by using [`enableTailwind()`](/docs/tailwind/enable-tailwind).
diff --git a/packages/docs/remark-shiki-twoslash/caching.js b/packages/docs/remark-shiki-twoslash/caching.js
index 88d1c18bb9..c9382b63ae 100644
--- a/packages/docs/remark-shiki-twoslash/caching.js
+++ b/packages/docs/remark-shiki-twoslash/caching.js
@@ -21,6 +21,13 @@ exports.cachedTwoslashCall = (code, lang, settings) => {
return runTwoSlash(code, lang, settings);
}
+ const { createHash } = require("crypto");
+ const { readFileSync, existsSync, mkdirSync, writeFileSync } = require("fs");
+ const { join } = require("path");
+
+ const shikiVersion = require("@typescript/twoslash/package.json").version;
+ const tsVersion = require("typescript/package.json").version;
+
const shasum = createHash("sha1");
const codeSha = shasum
.update(`${code}-${shikiVersion}-${tsVersion}`)
diff --git a/packages/docs/remark-shiki-twoslash/index.js b/packages/docs/remark-shiki-twoslash/index.js
index 0ac12a0170..2d0eb3ca73 100644
--- a/packages/docs/remark-shiki-twoslash/index.js
+++ b/packages/docs/remark-shiki-twoslash/index.js
@@ -143,14 +143,14 @@ const parseFence = (fence) => {
*/
function remarkTwoslash(settings = {}) {
if (!highlighterCache.has(settings)) {
- highlighterCache.set(settings, highlightersFromSettings(settings));
+ highlighterCache.set(settings, exports.highlightersFromSettings(settings));
}
const transform = async (markdownAST) => {
const highlighters = await highlighterCache.get(settings);
parsingNewFile();
// eslint-disable-next-line @typescript-eslint/no-use-before-define
- visit(markdownAST, "code", remarkVisitor(highlighters, settings));
+ visit(markdownAST, "code", exports.remarkVisitor(highlighters, settings));
};
return transform;
@@ -192,7 +192,8 @@ exports.remarkVisitor =
try {
// By allowing node.twoslash to already exist you can set it up yourself in a browser
twoslash =
- node.twoslash || runTwoSlashOnNode(code, fence, twoslashSettings);
+ node.twoslash ||
+ exports.runTwoSlashOnNode(code, fence, twoslashSettings);
} catch (error) {
const shouldAlwaysRaise =
process && process.env && Boolean(process.env.CI);
@@ -237,7 +238,7 @@ exports.setupForFile = async (settings = {}) => {
parsingNewFile();
if (!highlighterCache.has(settings)) {
- highlighterCache.set(settings, highlightersFromSettings(settings));
+ highlighterCache.set(settings, exports.highlightersFromSettings(settings));
}
const highlighters = await highlighterCache.get(settings);
@@ -252,7 +253,7 @@ exports.transformAttributesToHTML = (
) => {
const fence = parseFence(fenceString);
- const twoslash = runTwoSlashOnNode(code, fence, settings);
+ const twoslash = exports.runTwoSlashOnNode(code, fence, settings);
const newCode = (twoslash && twoslash.code) || code;
return getHTML(newCode, fence, highlighters, twoslash, settings);
};