Skip to content

πŸŽ₯ Make videos programmatically with React

run lerna link

Jonny Burgerff250b356da0
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 3fd6a748e3..1629f7e699 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -22,6 +22,9 @@ jobs:
- name: Install
run: pnpm recursive install --frozen-lockfile
+ - name: Link
+ run: pnpm lerna bootstrap
+
- run: pnpm run build
- name: Install and Build πŸ”§
diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index a1ba4d220c..e392c8c016 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -48,6 +48,9 @@ jobs:
- name: Install
run: pnpm recursive install --frozen-lockfile
+ - name: Link
+ run: pnpm lerna bootstrap
+
- name: Build & Test
run: |
pnpm run build
diff --git a/package.json b/package.json
index 0ebfa3c5dd..54d1108099 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
"prettier": "^2.2.1",
"prettier-plugin-organize-imports": "^1.1.1",
"sharp": "^0.29.0",
+ "remotion": "^2.4.3",
"ts-jest": "^27.0.5",
"typescript": "^4.4.2"
},
diff --git a/packages/docs/docs/dynamic-metadata.md b/packages/docs/docs/dynamic-metadata.md
index 4c66788f12..1139f3b65a 100644
--- a/packages/docs/docs/dynamic-metadata.md
+++ b/packages/docs/docs/dynamic-metadata.md
@@ -27,10 +27,10 @@ For example if you have passed `--props='{"hello": "world"}'` as a command line
```tsx twoslash
// It's better to fake type here than to import any
-const getInputProps = () => ({hello: 'world'} as const)
+const getInputProps = () => ({ hello: "world" } as const);
// ---cut---
-const {hello} = getInputProps()
-console.log(hello) // "world"
+const { hello } = getInputProps();
+console.log(hello); // "world"
```
You can use this technique to dynamically change the frame rate, dimensions or duration of our video as you render. For example, if you pass `--props={"duration": 100}` during rendering, the video will be 100 frames long if you define your composition as followed:
@@ -38,9 +38,9 @@ You can use this technique to dynamically change the frame rate, dimensions or d
```tsx twoslash
// @include: example-MyComponent
// ---cut---
-import {Composition, getInputProps} from 'remotion'
+import { Composition, getInputProps } from "remotion";
-const inputProps = getInputProps()
+const inputProps = getInputProps();
export const Index = () => {
return (
@@ -54,8 +54,8 @@ export const Index = () => {
durationInFrames={inputProps?.duration ?? 20}
/>
</>
- )
-}
+ );
+};
```
:::tip
@@ -72,23 +72,23 @@ In this example, we fetch the duration of "Big Buck Bunny" and use it to make ou
```tsx twoslash
// @include: example-VideoTesting
-import {useEffect, useState} from 'react'
-import {Composition, continueRender, delayRender} from 'remotion'
+import { useEffect, useState } from "react";
+import { Composition, continueRender, delayRender } from "remotion";
// ---cut---
export const Index: React.FC = () => {
- const [handle] = useState(() => delayRender())
- const [duration, setDuration] = useState(1)
+ const [handle] = useState(() => delayRender());
+ const [duration, setDuration] = useState(1);
useEffect(() => {
- const video = document.createElement('video')
+ const video = document.createElement("video");
video.src =
- 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4'
+ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4";
video.onloadedmetadata = () => {
- setDuration(Math.round(video.duration * 30))
- continueRender(handle)
- }
- }, [handle])
+ setDuration(Math.round(video.duration * 30));
+ continueRender(handle);
+ };
+ }, [handle]);
return (
<>
@@ -101,8 +101,8 @@ export const Index: React.FC = () => {
durationInFrames={duration}
/>
</>
- )
-}
+ );
+};
```
## Change metadata in server-side rendering
@@ -110,26 +110,26 @@ export const Index: React.FC = () => {
Both `getCompositions()` and `renderFrames()` functions accept an `inputProps` object as a parameter.
```tsx twoslash
-import {getCompositions} from '@remotion/renderer'
-const bundled: string = ''
+import { getCompositions } from "@remotion/renderer";
+const bundled: string = "";
// ---cut---
getCompositions(bundled, {
inputProps: {
- custom: 'data'
- }
-})
+ custom: "data",
+ },
+});
```
```tsx twoslash
-import {renderFrames as rf} from '@remotion/renderer'
-const renderFrames = (options: Partial<Parameters<typeof rf>[0]>) => {}
+import { renderFrames as rf } from "@remotion/renderer";
+const renderFrames = (options: { inputProps: {} }) => {};
// ---cut---
renderFrames({
// ...
inputProps: {
- custom: 'data'
- }
-})
+ custom: "data",
+ },
+});
```
Make sure to pass the parameter to both of these functions, so the input props are available to `getInputProps` during the composition fetching and rendering stage.
diff --git a/packages/docs/docs/render-frames.md b/packages/docs/docs/render-frames.md
index 29ec192915..20b6ae1f74 100644
--- a/packages/docs/docs/render-frames.md
+++ b/packages/docs/docs/render-frames.md
@@ -53,8 +53,8 @@ A callback that fires after the setup process (validation, browser launch) has f
```ts twoslash
const onStart = () => {
- console.log('Starting rendering...')
-}
+ console.log("Starting rendering...");
+};
```
### `onFrameUpdate`
@@ -63,8 +63,8 @@ A callback function that gets called whenever a frame finished rendering. An arg
```ts twoslash
const onFrameUpdate = (frame: number) => {
- console.log(`${frame} frames rendered.`)
-}
+ console.log(`${frame} frames rendered.`);
+};
```
### `outputDir`
@@ -134,7 +134,12 @@ The `frame` property tells you at which frame the error was thrown. If the error
```tsx twoslash
import {renderFrames as rf} from '@remotion/renderer'
-const renderFrames = (options: Partial<Parameters<typeof rf>[0]>) => {}
+const renderFrames = (options: {
+ onError: (info: {
+ frame: null | number;
+ error: Error
+ })
+}) => {}
// ---cut---
renderFrames({
onError: (info) => {
diff --git a/packages/docs/docs/render-still.md b/packages/docs/docs/render-still.md
index 7ef53599b7..35858bf7a0 100644
--- a/packages/docs/docs/render-still.md
+++ b/packages/docs/docs/render-still.md
@@ -16,26 +16,23 @@ You first need to bundle the project and fetch the compositions. Read [the code
```ts twoslash
// @module: ESNext
// @target: ESNext
-import {bundle} from '@remotion/bundler';
-import {
- getCompositions,
- renderStill
-} from '@remotion/renderer';
+import { bundle } from "@remotion/bundler";
+import { getCompositions, renderStill } from "@remotion/renderer";
// The composition you want to render
-const compositionId = 'HelloWorld'
+const compositionId = "HelloWorld";
-const bundleLocation = await bundle(require.resolve('./src/index'))
+const bundleLocation = await bundle(require.resolve("./src/index"));
const comps = await getCompositions(bundleLocation, {
inputProps: {
- custom: 'data',
+ custom: "data",
},
-})
-const composition = comps.find((c) => c.id === compositionId)
+});
+const composition = comps.find((c) => c.id === compositionId);
if (!composition) {
- throw new Error(`No composition with the ID ${compositionId} found`)
+ throw new Error(`No composition with the ID ${compositionId} found`);
}
// ---cut---
@@ -43,14 +40,17 @@ if (!composition) {
await renderStill({
composition,
webpackBundle: bundleLocation,
- output: '/tmp/still.png',
+ output: "/tmp/still.png",
onError: (error) => {
- console.error("The following error occured when rendering the still: ", error.message)
+ console.error(
+ "The following error occured when rendering the still: ",
+ error.message
+ );
},
inputProps: {
- custom: 'data'
- }
-})
+ custom: "data",
+ },
+});
```
## Arguments
@@ -118,8 +118,9 @@ _optional_
Allows you to react to an exception thrown in your React code. The callback has an argument which is the error.
```tsx twoslash
-import {renderStill as rs} from '@remotion/renderer'
-const renderStill = (options: Partial<Parameters<typeof rs>[0]>) => {}
+const renderStill = (options: {
+ onError: (err: Error)
+}) => {}
// ---cut---
renderStill({
// ... other arguments
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 298d786d3c..f1eee29dba 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -21,6 +21,7 @@ importers:
prettier-plugin-organize-imports: ^1.1.1
react: ^17.0.1
react-dom: ^17.0.1
+ remotion: ^2.4.3
sharp: ^0.29.0
three: ^0.128.0
ts-jest: ^27.0.5
@@ -45,6 +46,7 @@ importers:
jest-environment-jsdom: 27.2.4
prettier: 2.4.1
prettier-plugin-organize-imports: [email protected][email protected]
+ remotion: link:packages/core
sharp: 0.29.1
ts-jest: 27.0.5_52a571d76319e63aeaa66dc9db9e90cc
typescript: 4.4.3
@@ -64,7 +66,7 @@ importers:
prettier: ^2.0.5
prettier-plugin-organize-imports: ^1.1.1
react-refresh: ^0.9.0-rc.2
- remotion: ^2.4.2
+ remotion: ^2.4.3
typescript: ^4.4.2
webpack: 5.37.0
dependencies:
@@ -105,7 +107,7 @@ importers:
prettier: ^2.0.5
prettier-plugin-organize-imports: ^1.1.1
react-refresh: ^0.9.0-rc.2
- remotion: ^2.4.2
+ remotion: ^2.4.3
semver: 7.3.4
style-loader: ^2.0.0
typescript: ^4.4.2
@@ -140,10 +142,10 @@ importers:
packages/cli:
specifiers:
'@jonny/eslint-config': ^2.1.233
- '@remotion/bundler': ^2.4.2
- '@remotion/media-utils': ^2.4.2
- '@remotion/player': ^2.4.2
- '@remotion/renderer': ^2.4.2
+ '@remotion/bundler': ^2.4.3
+ '@remotion/media-utils': ^2.4.3
+ '@remotion/player': ^2.4.3
+ '@remotion/renderer': ^2.4.3
'@types/jest': ^27.0.2
'@types/node': ^16.7.5
'@types/react': 17.0.19
@@ -158,7 +160,7 @@ importers:
minimist: ^1.2.5
prettier: ^2.0.5
prettier-plugin-organize-imports: ^1.1.1
- remotion: ^2.4.2
+ remotion: ^2.4.3
semver: ^7.3.4
ts-jest: ^27.0.5
typescript: ^4.4.2
@@ -263,13 +265,13 @@ importers:
'@docusaurus/module-type-aliases': ^2.0.0-beta.6
'@docusaurus/preset-classic': 2.0.0-beta.6
'@mdx-js/react': ^1.6.21
- '@remotion/babel-loader': ^2.4.2
- '@remotion/bundler': ^2.4.2
- '@remotion/gif': ^2.4.2
- '@remotion/media-utils': ^2.4.2
- '@remotion/player': ^2.4.2
- '@remotion/renderer': ^2.4.2
- '@remotion/three': ^2.4.2
+ '@remotion/babel-loader': ^2.4.3
+ '@remotion/bundler': ^2.4.3
+ '@remotion/gif': ^2.4.3
+ '@remotion/media-utils': ^2.4.3
+ '@remotion/player': ^2.4.3
+ '@remotion/renderer': ^2.4.3
+ '@remotion/three': ^2.4.3
'@splitbee/web': ^0.2.4
'@tsconfig/docusaurus': ^1.0.4
'@types/color-namer': ^1.3.0
@@ -284,7 +286,7 @@ importers:
jest: ^27.2.4
polished: 4.1.2
react-player: ^2.9.0
- remotion: ^2.4.2
+ remotion: ^2.4.3
ts-jest: ^27.0.5
url-loader: ^4.1.1
dependencies:
@@ -368,15 +370,15 @@ importers:
'@babel/preset-react': 7.12.13
'@mdx-js/react': ^1.6.21
'@react-three/drei': ^4.3.3
- '@remotion/babel-loader': ^2.4.2
- '@remotion/bundler': ^2.4.2
- '@remotion/cli': ^2.4.2
+ '@remotion/babel-loader': ^2.4.3
+ '@remotion/bundler': ^2.4.3
+ '@remotion/cli': ^2.4.3
'@remotion/eslint-config': ^2.4.2
'@remotion/eslint-plugin': ^2.4.2
- '@remotion/gif': ^2.4.2
- '@remotion/media-utils': ^2.4.2
- '@remotion/renderer': ^2.4.2
- '@remotion/three': ^2.4.2
+ '@remotion/gif': ^2.4.3
+ '@remotion/media-utils': ^2.4.3
+ '@remotion/renderer': ^2.4.3
+ '@remotion/three': ^2.4.3
'@types/babel__core': ^7.1.12
'@types/babel__template': ^7.4.0
'@types/express': ^4.17.11
@@ -390,7 +392,7 @@ importers:
polished: ^4.0.5
prettier: ^2.0.5
prettier-plugin-organize-imports: ^1.1.1
- remotion: ^2.4.2
+ remotion: ^2.4.3
styled-components: ^5.1.1
svg-path-properties: ^1.0.4
three: '>=0.128.0'
@@ -451,7 +453,7 @@ importers:
jest: ^27.2.4
lru_map: ^0.4.1
prettier-plugin-organize-imports: ^1.1.1
- remotion: ^2.4.2
+ remotion: ^2.4.3
ts-jest: ^27.0.5
typescript: ^4.4.2
webpack: 5.37.0
@@ -480,7 +482,7 @@ importers:
eslint: ^7.25.0
prettier: ^2.0.5
prettier-plugin-organize-imports: ^1.1.1
- remotion: ^2.4.2
+ remotion: ^2.4.3
typescript: ^4.4.2
dependencies:
remotion: link:../core
@@ -506,7 +508,7 @@ importers:
jest: ^27.2.4
prettier: ^2.0.5
prettier-plugin-organize-imports: ^1.1.1
- remotion: ^2.4.2
+ remotion: ^2.4.3
ts-jest: ^27.0.5
typescript: ^4.4.2
webpack: ^5.21.2
@@ -532,7 +534,7 @@ importers:
packages/player-example:
specifiers:
'@craco/craco': ^6.1.1
- '@remotion/player': ^2.4.2
+ '@remotion/player': ^2.4.3
'@testing-library/jest-dom': ^5.11.4
'@testing-library/react': ^11.1.0
'@testing-library/user-event': ^12.1.10
@@ -543,7 +545,7 @@ importers:
react: ^17.0.1
react-dom: ^17.0.1
react-scripts: 4.0.3
- remotion: ^2.4.2
+ remotion: ^2.4.3
typescript: ^4.4.2
dependencies:
'@craco/craco': [email protected]
@@ -564,7 +566,7 @@ importers:
packages/renderer:
specifiers:
'@jonny/eslint-config': ^2.1.233
- '@remotion/bundler': ^2.4.2
+ '@remotion/bundler': ^2.4.3
'@testing-library/react': ^11.2.5
'@types/jest': ^27.0.2
'@types/node': ^16.7.5
@@ -577,7 +579,7 @@ importers:
prettier: ^2.0.5
prettier-plugin-organize-imports: ^1.1.1
puppeteer-core: ^10.2.0
- remotion: ^2.4.2
+ remotion: ^2.4.3
sanitize-filename: ^1.6.3
serve-handler: ^6.1.3
ts-jest: 26.5.1
@@ -614,7 +616,7 @@ importers:
eslint: ^7.4.0
prettier: ^2.0.5
prettier-plugin-organize-imports: ^1.1.1
- remotion: ^2.4.2
+ remotion: ^2.4.3
three: ^0.133.0
typescript: ^4.4.2
dependencies:
@@ -8138,7 +8140,7 @@ packages:
/axios/0.21.4:
resolution: {integrity: sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==}
dependencies:
- follow-redirects: [email protected]
+ follow-redirects: 1.14.4
transitivePeerDependencies:
- debug
dev: false
@@ -12038,7 +12040,7 @@ packages:
react: 17.0.2
dev: false
- /follow-redirects/[email protected]:
+ /follow-redirects/1.14.4:
resolution: {integrity: sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==}
engines: {node: '>=4.0'}
peerDependencies:
@@ -12046,8 +12048,6 @@ packages:
peerDependenciesMeta:
debug:
optional: true
- dependencies:
dev: false
/for-in/1.0.2:
@@ -12976,7 +12976,7 @@ packages:
engines: {node: '>=8.0.0'}
dependencies:
eventemitter3: 4.0.7
- follow-redirects: [email protected]
+ follow-redirects: 1.14.4
requires-port: 1.0.0
transitivePeerDependencies:
- debug