🎥 Make videos programmatically with React
add to docs
Jonny Burger7dbb373ae0b5
diff --git a/packages/docs/docs/cloudrun/rendermediaoncloudrun.md b/packages/docs/docs/cloudrun/rendermediaoncloudrun.mdindex 5a554ad3da..a34b4bab6b 100644--- a/packages/docs/docs/cloudrun/rendermediaoncloudrun.md+++ b/packages/docs/docs/cloudrun/rendermediaoncloudrun.md@@ -30,7 +30,7 @@ const result = await renderMediaOnCloudrun({"https://storage.googleapis.com/remotioncloudrun-123asd321/sites/abcdefgh",codec: "h264",});-if (result.status === "success") {+if (result.type === "success") {console.log(result.bucketName);console.log(result.renderId);}@@ -275,22 +275,26 @@ Render a silent audio track if there wouldn't be any otherwise.Uses a lossless audio codec, if one is available for the codec. If you set audioCodec, it takes priority over preferLossless.+### `offthreadVideoCacheSize?`<AvailableFrom v="4.0.23"/>++<Options id="offthreadvideo-cache-size" />+## Return valueReturns a promise resolving to an object.-### `status`+### `type`Use this to determine the structure of the response. It can either be:- 'success' - render has been performed successfully.- 'crash - Cloud Run service has crashed.-## Return when status === 'success'+## Return when type === 'success'The resulting object contains the following:-### `status`+### `type`'success' - render has been performed successfully.@@ -327,11 +331,11 @@ Google Storage path, beginning with `gs://{bucket-name}`. Can be used with the [Size of the rendered media in KB.-## Return when status === 'crash'+## Return when type === 'crash'The resulting object contains the following:-### `status`+### `type`'crash' - Cloud Run service has crashed without a response.diff --git a/packages/docs/docs/cloudrun/renderstilloncloudrun.md b/packages/docs/docs/cloudrun/renderstilloncloudrun.mdindex 0baf3506f5..8f0d5b088e 100644--- a/packages/docs/docs/cloudrun/renderstilloncloudrun.md+++ b/packages/docs/docs/cloudrun/renderstilloncloudrun.md@@ -31,8 +31,10 @@ const result = await renderStillOnCloudrun({"https://storage.googleapis.com/remotioncloudrun-123asd321/sites/abcdefgh",});-console.log(result.bucketName);-console.log(result.renderId);+if (result.type === "success") {+ console.log(result.bucketName);+ console.log(result.renderId);+}```## Arguments@@ -180,6 +182,10 @@ _optional_A number describing how long the render may take to resolve all [`delayRender()`](/docs/delay-render) calls [before it times out](/docs/timeout). Default: `30000`+### `offthreadVideoCacheSize?`<AvailableFrom v="4.0.23"/>++<Options id="offthreadvideo-cache-size" />+## Return valueReturns a promise resolving to an object containing the following:diff --git a/packages/docs/docs/cloudrun/setup.md b/packages/docs/docs/cloudrun/setup.mdindex 2e5a9eed15..8989b6bd15 100644--- a/packages/docs/docs/cloudrun/setup.md+++ b/packages/docs/docs/cloudrun/setup.md@@ -373,7 +373,7 @@ const result = await renderMediaOnCloudrun({updateRenderProgress,});-if (result.status === "success") {+if (result.type === "success") {console.log(result.bucketName);console.log(result.renderId);}@@ -411,7 +411,7 @@ const url = "string";const serviceName = "string";// ---cut----const { renderId, bucketName } = await renderStillOnCloudrun({+const result = await renderStillOnCloudrun({serviceName,region: "us-east1",serveUrl: url,@@ -419,6 +419,11 @@ const { renderId, bucketName } = await renderStillOnCloudrun({inputProps: {},imageFormat: "jpeg",});++if (result.type === "success") {+ console.log(result.bucketName);+ console.log(result.renderId);+}```The render will now run and after a while the image will be available in your cloud storage bucket.diff --git a/packages/docs/docs/lambda/getcompositionsonlambda.md b/packages/docs/docs/lambda/getcompositionsonlambda.mdindex 539737c169..c23615448a 100644--- a/packages/docs/docs/lambda/getcompositionsonlambda.md+++ b/packages/docs/docs/lambda/getcompositionsonlambda.md@@ -114,6 +114,10 @@ Specify a specific bucket name to be used. [This is not recommended](/docs/lambdOne of `verbose`, `info`, `warn`, `error`. Determines how much is being logged inside the Lambda function. Logs can be read through the CloudWatch URL that this function returns.+### `offthreadVideoCacheSize?`<AvailableFrom v="4.0.23"/>++<Options id="offthreadvideo-cache-size" />+### ~~`dumpBrowserLogs?`~~_optional - default `false`, deprecated in v4.0_diff --git a/packages/docs/docs/lambda/rendermediaonlambda.md b/packages/docs/docs/lambda/rendermediaonlambda.mdindex 0a81926fe1..745bc9ae9c 100644--- a/packages/docs/docs/lambda/rendermediaonlambda.md+++ b/packages/docs/docs/lambda/rendermediaonlambda.md@@ -345,6 +345,10 @@ One of `verbose`, `info`, `warn`, `error`. Determines how much is being logged iIf the `logLevel` is set to `verbose`, the Lambda function will not clean up artifacts, to aid debugging. Do not use it unless you are debugging a problem.+### `offthreadVideoCacheSize?`<AvailableFrom v="4.0.23"/>++<Options id="offthreadvideo-cache-size" />+### ~~`dumpBrowserLogs?`~~_optional - default `false`, deprecated in v4.0_diff --git a/packages/docs/docs/lambda/renderstillonlambda.md b/packages/docs/docs/lambda/renderstillonlambda.mdindex 28e36d6c67..b0b3b0fd2c 100644--- a/packages/docs/docs/lambda/renderstillonlambda.md+++ b/packages/docs/docs/lambda/renderstillonlambda.md@@ -205,6 +205,10 @@ _optional_Allows you to set certain Chromium / Google Chrome flags. See: [Chromium flags](/docs/chromium-flags).+### `offthreadVideoCacheSize?`<AvailableFrom v="4.0.23"/>++<Options id="offthreadvideo-cache-size" />+#### `disableWebSecurity`_boolean - default `false`_diff --git a/packages/docs/docs/renderer/get-compositions.md b/packages/docs/docs/renderer/get-compositions.mdindex b31bca5101..3247986e32 100644--- a/packages/docs/docs/renderer/get-compositions.md+++ b/packages/docs/docs/renderer/get-compositions.md@@ -16,7 +16,7 @@ For every compositions their [`calculateMetadata()`](/docs/composition#calculate```tsconst getCompositions: (bundleOrServeUrl: string,- options?: GetCompositionsConfig+ options?: GetCompositionsConfig,) => Promise<TComposition[]>;```@@ -115,7 +115,7 @@ getCompositions({.map((stack) => {return ` ${stack.url}:${stack.lineNumber}:${stack.columnNumber}`;})- .join("\n")+ .join("\n"),);},});@@ -136,6 +136,10 @@ _optional_Allows you to set certain Chromium / Google Chrome flags. See: [Chromium flags](/docs/chromium-flags).+### `offthreadVideoCacheSize?`<AvailableFrom v="4.0.23"/>++<Options id="offthreadvideo-cache-size" />+#### ~~`ffmpegExecutable`~~_removed in v4.0, optional_diff --git a/packages/docs/docs/renderer/render-frames.md b/packages/docs/docs/renderer/render-frames.mdindex be788127bc..620c24d0d8 100644--- a/packages/docs/docs/renderer/render-frames.md+++ b/packages/docs/docs/renderer/render-frames.md@@ -54,7 +54,7 @@ In `v3.2.30`, a third argument was rendered: `timeToRenderInMilliseconds`, descrconst onFrameUpdate = (framesRendered: number,frame: number,- timeToRenderInMilliseconds: number+ timeToRenderInMilliseconds: number,) => {console.log(`${framesRendered} frames rendered.`);@@ -201,7 +201,7 @@ renderFrames({.map((stack) => {return ` ${stack.url}:${stack.lineNumber}:${stack.columnNumber}`;})- .join("\n")+ .join("\n"),);},});@@ -287,6 +287,10 @@ Accepted values:Lets you set a custom user agent that the headless Chrome browser assumes.+### `offthreadVideoCacheSize?`<AvailableFrom v="4.0.23"/>++<Options id="offthreadvideo-cache-size" />+### ~~`quality?`~~Renamed to `jpegQuality` in `v4.0.0`.diff --git a/packages/docs/docs/renderer/render-media.md b/packages/docs/docs/renderer/render-media.mdindex e373baf395..5272ab347a 100644--- a/packages/docs/docs/renderer/render-media.md+++ b/packages/docs/docs/renderer/render-media.md@@ -401,6 +401,10 @@ Before you use this hack, reach out to the Remotion team on [Discord](https://reDisallows the renderer from doing rendering frames and encoding at the same time. This makes the rendering process more memory-efficient, but possibly slower.+### `offthreadVideoCacheSize?`<AvailableFrom v="4.0.23"/>++<Options id="offthreadvideo-cache-size" />+### ~~`parallelism?`~~Renamed to `concurrency` in v3.2.17.diff --git a/packages/docs/docs/renderer/render-still.md b/packages/docs/docs/renderer/render-still.mdindex fd920bf1e1..76fcc2c168 100644--- a/packages/docs/docs/renderer/render-still.md+++ b/packages/docs/docs/renderer/render-still.md@@ -201,6 +201,10 @@ Default: `null`.Lets you set a custom user agent that the headless Chrome browser assumes.+### `offthreadVideoCacheSize?`<AvailableFrom v="4.0.23"/>++<Options id="offthreadvideo-cache-size" />+### ~~`dumpBrowserLogs?`~~_optional - default `false`, deprecated in v4.0_diff --git a/packages/docs/docs/renderer/select-composition.md b/packages/docs/docs/renderer/select-composition.mdindex 7da668e40a..fc490585b6 100644--- a/packages/docs/docs/renderer/select-composition.md+++ b/packages/docs/docs/renderer/select-composition.md@@ -82,6 +82,10 @@ An object containing environment variables to be injected in your project.See: [Environment variables](/docs/env-variables/)+### `offthreadVideoCacheSize?`<AvailableFrom v="4.0.23"/>++<Options id="offthreadvideo-cache-size" />+## See also- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/renderer/src/select-composition.ts)diff --git a/packages/docs/src/components/Options.tsx b/packages/docs/src/components/Options.tsxnew file mode 100644index 0000000000..b05d210fc8--- /dev/null+++ b/packages/docs/src/components/Options.tsx@@ -0,0 +1,22 @@+import { BrowserSafeApis } from "@remotion/renderer/client";+import React from "react";++export const Options: React.FC<{+ id: string;+}> = ({ id }) => {+ const option = getOption(id);++ return <>{option.description}</>;+};++const options = Object.values(BrowserSafeApis.options);++const getOption = (id: string) => {+ const option = options.find((o) => o.cliFlag === id);++ if (!option) {+ throw new Error('Unknown option "' + id + '"');+ }++ return option;+};diff --git a/packages/docs/src/theme/MDXComponents.js b/packages/docs/src/theme/MDXComponents.jsindex 46eee19886..7c91db111c 100644--- a/packages/docs/src/theme/MDXComponents.js+++ b/packages/docs/src/theme/MDXComponents.js@@ -4,6 +4,7 @@ import { Demo } from "../../components/demos";import { ExperimentalBadge } from "../../components/Experimental";import { InlineStep, Step } from "../../components/InlineStep";import { AvailableFrom } from "../components/AvailableFrom";+import { Options } from "../components/Options";export default {...MDXComponents,@@ -12,4 +13,5 @@ export default {Step,Demo,AvailableFrom,+ Options,};diff --git a/packages/renderer/src/client.ts b/packages/renderer/src/client.tsindex 109cb070b4..cee563949b 100644--- a/packages/renderer/src/client.ts+++ b/packages/renderer/src/client.ts@@ -20,6 +20,7 @@ import {crfOption} from './options/crf';import {enforceAudioOption} from './options/enforce-audio';import {jpegQualityOption} from './options/jpeg-quality';import {muteOption} from './options/mute';+import {offthreadVideoCacheSizeOption} from './options/offthreadvideo-cache-size';import {scaleOption} from './options/scale';import {videoBitrate} from './options/video-bitrate';import {videoCodecOption} from './options/video-codec';@@ -53,6 +54,7 @@ export const BrowserSafeApis = {enforceAudioOption,muteOption,videoCodecOption,+ offthreadVideoCacheSizeOption,},codecSupportsCrf,codecSupportsVideoBitrate,diff --git a/packages/renderer/src/options/offthreadvideo-cache-size.tsx b/packages/renderer/src/options/offthreadvideo-cache-size.tsxindex 4c8aa62226..330436edb4 100644--- a/packages/renderer/src/options/offthreadvideo-cache-size.tsx+++ b/packages/renderer/src/options/offthreadvideo-cache-size.tsx@@ -7,12 +7,15 @@ export const offthreadVideoCacheSizeOption = {<>From v4.0, Remotion has a cache for{' '}<a href="https://remotion.dev/docs/offthreadvideo">- <code>OffthreadVideo</code>+ <code><OffthreadVideo></code></a>{' '}frames. The default is dependent on the available memory when the render- starts. This option allows to override the number of video frames that+ starts.+ <br /> This option allows to override the number of video frames thatshould be kept in cache. The higher it is, the faster the render will be,but the more memory will be used.+ <br />+ Default: <code>null</code></>),ssrName: 'offthreadVideoCacheSize' as const,