🎥 Make videos programmatically with React
mostly docs
Jonny Burger21665a6e101e
diff --git a/packages/docs/blog/2021-02-11-remotion1-1.md b/packages/docs/blog/2021-02-11-remotion1-1.mdindex 8ba22968aa..4ae9e56aa9 100644--- a/packages/docs/blog/2021-02-11-remotion1-1.md+++ b/packages/docs/blog/2021-02-11-remotion1-1.md@@ -22,7 +22,7 @@ When providing the possibility on how to configure Remotion, it was of big impor`remotion.config.ts````ts-import {overrideWebpackConfig} from '@remotion/bundler';+import { overrideWebpackConfig } from "@remotion/bundler";overrideWebpackConfig((currentConfiguration) => {return {@@ -56,7 +56,7 @@ To prevent shooting yourself into your foot, Remotion now comes with an ESLint rSimply type-```console+```npm run upgrade```diff --git a/packages/docs/blog/2021-02-15-remotion-1-3.md b/packages/docs/blog/2021-02-15-remotion-1-3.mdindex 9226062454..c747b4f63d 100644--- a/packages/docs/blog/2021-02-15-remotion-1-3.md+++ b/packages/docs/blog/2021-02-15-remotion-1-3.md@@ -15,7 +15,7 @@ Only 1 week after the initial launch, here is Remotion 1.3! In just 7 days, we hRemotion 1.1-```console+```hyperfine --min-runs 5 'npm run build -- --overwrite --concurrency=16'Benchmark #1: npm run build -- --overwrite --concurrency=16Time (mean ± σ): 98.972 s ± 0.650 s [User: 123.329 s, System: 10.103 s]@@ -24,7 +24,7 @@ Benchmark #1: npm run build -- --overwrite --concurrency=16Remotion 1.3-```console+```hyperfine --min-runs 5 'npm run build -- --overwrite --concurrency=16'Benchmark #1: npm run build -- --overwrite --concurrency=16Time (mean ± σ): 17.921 s ± 0.224 s [User: 36.492 s, System: 3.482 s]@@ -44,8 +44,8 @@ My goal was to force Typescript on everybody - but I failed. Support for plain JMany options which you could pass in via CLI flags, you can now also add by adding a `remotion.config.ts` file in the repo. For example, if you want to increase the parallelism to the amount of threads you have and never want to write `--overwrite`, you can add the following to the config file:```tsx-import os from 'os';-import {Config} from 'remotion';+import os from "os";+import { Config } from "remotion";Config.Rendering.setConcurrency(os.cpus().length);Config.Output.setOverwriteOutput(true);@@ -58,13 +58,13 @@ You can see all the [options on this page](https://www.remotion.dev/docs/config)While there was an Easing API, it was undocumented. Learn which [Easing methods](/docs/easing) are available and how to use it with [`interpolate()`](/docs/interpolate)!```tsx-import {interpolate, Easing} from 'remotion';+import { interpolate, Easing } from "remotion";interpolate(frame, [0, 100], {easing: Easing.bezier(0.8, 0.22, 0.96, 0.65),- extrapolateLeft: 'clamp',- extrapolateRight: 'clamp',-})+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+});```## The small thingsdiff --git a/packages/docs/blog/2021-08-11-remotion-2-3.md b/packages/docs/blog/2021-08-11-remotion-2-3.mdindex 1857f2d0b5..bffb76634b 100644--- a/packages/docs/blog/2021-08-11-remotion-2-3.md+++ b/packages/docs/blog/2021-08-11-remotion-2-3.md@@ -17,7 +17,7 @@ So far we focused on streamlining the workflow for making videos. While it was a[This new component](/docs/still) is the same as [`<Composition />`](/docs/composition) but is meant for defining a compositions that output a still image. Since it's already implied, you don't have to define the `fps` and `durationInFrames` properties.```tsx twoslash-import {Still} from 'remotion';+import { Still } from "remotion";const Thumbnail: React.FC = () => null;// ---cut---<Still@@ -26,11 +26,11 @@ const Thumbnail: React.FC = () => null;width={1200}height={627}defaultProps={{- title: 'Welcome to Remotion',- description: 'Edit Video.tsx to change template',- slogan: 'Write videos\nin React',+ title: "Welcome to Remotion",+ description: "Edit Video.tsx to change template",+ slogan: "Write videos\nin React",}}-/>+/>;```## Optimized editor for stills@@ -52,7 +52,7 @@ For still images, you don't need the timeline, so it will hide itself and give yRendering stills has become easier as well. The new `remotion still` command allows you to quickly generate a PNG or JPEG on the command line.-```console+```npx remotion still --props='{"custom": "data"}' src/index.tsx my-comp out.png```@@ -63,26 +63,23 @@ If you render using the Node.JS APIs, we have a new equivalent API for rendering```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---@@ -90,14 +87,17 @@ if (!composition) {await renderStill({composition,serveUrl: 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",+ },+});```## New Stills template with server renderingdiff --git a/packages/docs/docs/lambda-changelog.md b/packages/docs/docs/lambda-changelog.mdindex 99b71601f7..7a99a2ea3f 100644--- a/packages/docs/docs/lambda-changelog.md+++ b/packages/docs/docs/lambda-changelog.md@@ -14,6 +14,12 @@ Keep track of changes to the APIs of Remotion Lambda here.1. Redeploy your function: `npx remotion lambda functions deploy`1. Migrate according to the changelog below:+## Unreleased++- `renderStillOnLambda()` returns a `renderId` now+- Documented `downloadVideo()` method+- `downloadVideo()` return value property renamed from `size` to `sizeInBytes`+## October 29th, 2021Version hash: `3.0.0-lambda.42+838a7a013`diff --git a/packages/docs/docs/lambda-cli.md b/packages/docs/docs/lambda-cli.mdindex 76472b9a5f..232e94a1be 100644--- a/packages/docs/docs/lambda-cli.md+++ b/packages/docs/docs/lambda-cli.md@@ -13,7 +13,7 @@ You can get a list of all commands using `npx remotion lambda --help`.Selects an AWS region: For example:-```console+```--region=eu-central-1```@@ -29,7 +29,7 @@ Skips confirmation when doing a destructive action.Uploads a Remotion project to an S3 bucket. You will get a URL which you can pass to the `render` command to render the video.-```console+```npx remotion lambda sites create src/index.ts```@@ -37,7 +37,7 @@ npx remotion lambda sites create src/index.tsLists the sites uploaded to the S3 buckets-```console+```npx remotion lambda sites ls```@@ -45,7 +45,7 @@ npx remotion lambda sites lsDeletes a site from an S3 bucket.-```console+```npx remotion lambda sites rm f87nffa```@@ -113,7 +113,7 @@ npx remotion lambda functions deployList the functions deployed to your AWS account.-```console+```npx remotion lambda functions ls```@@ -121,7 +121,7 @@ npx remotion lambda functions lsRemoves a render function from your AWS account.-```console+```npx remotion lambda functions rm remotion lambda-4y2y1aaf```diff --git a/packages/docs/docs/lambda-downloadvideo.md b/packages/docs/docs/lambda-downloadvideo.mdindex 25ed8a5b14..ca892cba67 100644--- a/packages/docs/docs/lambda-downloadvideo.md+++ b/packages/docs/docs/lambda-downloadvideo.md@@ -4,4 +4,57 @@ title: downloadVideo()slug: /lambda/downloadvideo----TODO+Downloads a rendered video to your local disk.++```ts twoslash+// @module: ESNext+// @target: ESNext+import { downloadVideo } from "@remotion/lambda";++const { outputPath, size } = await downloadVideo({+ bucketName: "remotionlambda-r42fs9fk",+ region: "us-east-1",+ renderId: "8hfxlw",+ outPath: "out.mp4",+});++console.log(outputPath); // "/Users/yourname/remotion-project/out.mp4"+console.log(size); // 21249541+```++## Arguments++An object with the following properties:++### `region`++The [AWS region](/docs/lambda/region-selection) in which the render has performed.++### `bucketName`++The bucket name in which you the video was stored. This should be the same variable you used for `renderVideoOnLambda()`.++### `renderId`++The ID of the render. You can retrieve this ID by calling [`renderVideoOnLambda()`](/docs/lambda/rendervideoonlambda) or [`renderStillOnLambda()`](/docs/lambda/renderstillonlambda).++### `outPath`++Where the video should be saved. Pass an absolute path, or it will be resolved relative to your current working directory.++## Return value++Returns a promise resolving to an object with the following properties:++### `outputPath`++The absolute path of where the file got saved.++### `sizeInBytes`++The size of the file in bytes.++## See also++- [renderVideoOnLambda()](/docs/lambda/rendervideoonlambda)+- [renderStillOnLambda()](/docs/lambda/render-still-on-lambda)diff --git a/packages/docs/docs/lambda-setup.md b/packages/docs/docs/lambda-setup.mdindex 82bbc7c4db..2f9fad8ca1 100644--- a/packages/docs/docs/lambda-setup.md+++ b/packages/docs/docs/lambda-setup.md@@ -9,24 +9,32 @@ import TabItem from '@theme/TabItem';## 1. Install `@remotion/lambda`-Check the newest version number in the #lambda Discord channel+Check the newest version number in the #lambda Discord channel (link at the top of the page)```npm i @remotion/lambda@<version-number>```-Also update **all the other Remotion packages** to have the same version: `remotion`, `@remotion/cli`, `@remotion/bundler` Make sure no package version number has a `^` character in front of it as it will install a different version.+Also update **all the other Remotion packages** to have the same version: `remotion`, `@remotion/cli`, `@remotion/bundler`++:::tip+Make sure no package version number has a `^` character in front of it as it will install a different version.+:::Your package.json should look like the following:```json- "@remotion/bundler": "2.4.0-alpha.[versionhash]",- "@remotion/cli": "2.4.0-alpha.[versionhash]",- "@remotion/lambda": "2.4.0-alpha.[versionhash]",+ "@remotion/bundler": "3.0.0-lambda.[versionhash]",+ "@remotion/cli": "3.0.0-lambda.[versionhash]",+ "@remotion/lambda": "3.0.0-lambda.[versionhash]",// ...- "remotion": "2.4.0-alpha.[versionhash]",+ "remotion": "3.0.0-lambda.[versionhash]",```+:::tip+You can install `@remotion/lambda` in any project, not just a Remotion one, but remember to install `react` and `react-dom` peer dependencies+:::+## 2. Create role policy- Go to AWS account IAM sectiondiff --git a/packages/docs/docs/lambda.md b/packages/docs/docs/lambda.mdindex a19bd9b577..8cfb157a1c 100644--- a/packages/docs/docs/lambda.md+++ b/packages/docs/docs/lambda.md@@ -30,14 +30,6 @@ title: "@remotion/lambda"[**See here**](/docs/lambda/setup)-## Considerations--Currently hardcoded but you will need to decide in the future:--- Decide memory limit-- Decide lambda timeout-- Decide parallelism-## Region selectionStarting from release `2.2.0-alpha.6c60bafb`, you can select an AWS region (previously `eu-central-1` was hardcoded) using the `AWS_REGION` environment variable. The default value is `us-east-1`.@@ -95,12 +87,10 @@ Everything you can do using the CLI, you can also control using Node.JS APIs. Re## Known issues-- [ ] Sometimes an error `Unable to spawn browser` is shown - you can ignore it- [ ] AWS permissions are looser than necessary- [ ] Permission validation command sometimes breaks- [ ] Costs are not calculated accurately (probably slightly higher than effective)- [ ] Rendering using more than 1000 chunks is undefined behavior, things will break-- [ ] There is no way to disable chunk optimization## Licensediff --git a/packages/docs/docs/renderstillonlambda.md b/packages/docs/docs/renderstillonlambda.mdindex d380e51d91..5be221747b 100644--- a/packages/docs/docs/renderstillonlambda.md+++ b/packages/docs/docs/renderstillonlambda.md@@ -15,25 +15,22 @@ If you want to render a still locally instead, use [`renderStill()`](/docs/rende```tsx twoslash// @module: esnext// @target: es2017-import {renderStillOnLambda} from '@remotion/lambda';+import { renderStillOnLambda } from "@remotion/lambda";// ---cut----const {- estimatedPrice,- url,- size-} = await renderStillOnLambda({- region: 'us-east-1',- functionName: 'remotion-render-bds9aab',- serveUrl: 'https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw',- composition: 'MyVideo',+const { estimatedPrice, url, size } = await renderStillOnLambda({+ region: "us-east-1",+ functionName: "remotion-render-bds9aab",+ serveUrl:+ "https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw",+ composition: "MyVideo",inputProps: {},- imageFormat: 'png',+ imageFormat: "png",maxRetries: 3,- privacy: 'public',+ privacy: "public",envVariables: {},- frame: 10-})+ frame: 10,+});```## Arguments@@ -113,10 +110,14 @@ An AWS S3 URL where the output is available.Object containing roughly estimated information about how expensive this operation was.-### `size`+### `sizeInBytes`The size of the output image in bytes.+### `renderId`++A unique alphanumeric identifier for this render. Useful for obtaining status and finding the relevant files in the S3 bucket.+## See also- [renderVideoOnLambda()](/docs/lambda/rendervideoonlambda)diff --git a/packages/lambda/src/api/download-video.ts b/packages/lambda/src/api/download-video.tsindex 62a7ac728d..cb1cbbb493 100644--- a/packages/lambda/src/api/download-video.ts+++ b/packages/lambda/src/api/download-video.ts@@ -15,7 +15,7 @@ type DownloadVideoInput = {type DownloadVideoOutput = {outputPath: string;- size: number;+ sizeInBytes: number;};export const downloadVideo = async (@@ -50,6 +50,6 @@ export const downloadVideo = async (const {size} = await fs.promises.stat(outputPath);return {outputPath,- size,+ sizeInBytes: size,};};diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda/src/api/render-still-on-lambda.tsindex 4044bf125b..0076c4eb59 100644--- a/packages/lambda/src/api/render-still-on-lambda.ts+++ b/packages/lambda/src/api/render-still-on-lambda.ts@@ -65,5 +65,6 @@ export const renderStillOnLambda = async ({url: res.output,size: res.size,bucketName: res.bucketName,+ renderId: res.renderId,};};diff --git a/packages/lambda/src/functions/still.ts b/packages/lambda/src/functions/still.tsindex 90444cf907..46e6e864c8 100644--- a/packages/lambda/src/functions/still.ts+++ b/packages/lambda/src/functions/still.ts@@ -169,6 +169,7 @@ export const innerStillHandler = async (size,bucketName,estimatedPrice: formatCostsInfo(estimatedPrice),+ renderId,};};