🎥 Make videos programmatically with React
Rename parallelism parameters to concurrency
Jonny Burgered0168c1d04d
diff --git a/packages/cli/src/get-cli-options.ts b/packages/cli/src/get-cli-options.tsindex 28f140c588..cd0f4ca6c9 100644--- a/packages/cli/src/get-cli-options.ts+++ b/packages/cli/src/get-cli-options.ts@@ -244,13 +244,13 @@ export const getCliOptions = async (options: {const numberOfGifLoops =ConfigInternals.getAndValidateNumberOfGifLoops(codec);- const parallelism = ConfigInternals.getConcurrency();+ const concurrency = ConfigInternals.getConcurrency();- RenderInternals.validateConcurrency(parallelism, 'concurrency');+ RenderInternals.validateConcurrency(concurrency, 'concurrency');return {puppeteerTimeout: ConfigInternals.getCurrentPuppeteerTimeout(),- parallelism,+ concurrency,frameRange,shouldOutputImageSequence,codec,diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsxindex beadafc6d1..340c42f461 100644--- a/packages/cli/src/render.tsx+++ b/packages/cli/src/render.tsx@@ -56,7 +56,7 @@ export const render = async (remotionRoot: string) => {const {codec,proResProfile,- parallelism,+ concurrency,frameRange,shouldOutputImageSequence,overwrite,@@ -211,7 +211,7 @@ export const render = async (remotionRoot: string) => {rendering: {frames: renderedFrames,totalFrames: totalFrames.length,- concurrency: RenderInternals.getActualConcurrency(parallelism),+ concurrency: RenderInternals.getActualConcurrency(concurrency),doneIn: renderedDoneIn,steps,},@@ -270,7 +270,7 @@ export const render = async (remotionRoot: string) => {everyNthFrame,envVariables,frameRange,- parallelism,+ concurrency,puppeteerInstance,quality,timeoutInMilliseconds: puppeteerTimeout,@@ -312,7 +312,7 @@ export const render = async (remotionRoot: string) => {},puppeteerInstance,overwrite,- parallelism,+ concurrency,pixelFormat,proResProfile,quality,diff --git a/packages/docs/blog/2021-02-15-remotion-1-3.md b/packages/docs/blog/2021-02-15-remotion-1-3.mdindex c747b4f63d..61087893c8 100644--- a/packages/docs/blog/2021-02-15-remotion-1-3.md+++ b/packages/docs/blog/2021-02-15-remotion-1-3.md@@ -41,7 +41,7 @@ My goal was to force Typescript on everybody - but I failed. Support for plain J## Type-safe configuration file-Many 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:+Many 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 concurrency to the amount of threads you have and never want to write `--overwrite`, you can add the following to the config file:```tsximport os from "os";@@ -58,7 +58,7 @@ 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 { Easing, interpolate } from "remotion";interpolate(frame, [0, 100], {easing: Easing.bezier(0.8, 0.22, 0.96, 0.65),diff --git a/packages/docs/docs/parametrized-rendering.md b/packages/docs/docs/parametrized-rendering.mdindex e9c9e7e270..cc71ae058e 100644--- a/packages/docs/docs/parametrized-rendering.md+++ b/packages/docs/docs/parametrized-rendering.md@@ -36,7 +36,6 @@ export const MyComponent: React.FC<{ propOne: string; propTwo: number }> = () =>null;// @filename: Root.tsx-import React from "react";// ---cut---import { Composition } from "remotion";import { MyComponent } from "./MyComponent";@@ -110,7 +109,6 @@ await renderFrames({serveUrl: bundled,onStart: () => undefined,onFrameUpdate: (f) => undefined,- parallelism: null,outputDir: framesDir,inputProps: {titleText: "Hello World",diff --git a/packages/docs/docs/renderer/render-frames.md b/packages/docs/docs/renderer/render-frames.mdindex 88e59e40d9..cbcd54e9e3 100644--- a/packages/docs/docs/renderer/render-frames.md+++ b/packages/docs/docs/renderer/render-frames.md@@ -67,11 +67,15 @@ A `string` which must be either `png`, `jpeg` or `none`.- Choose `png` if you want your image sequence to have an alpha channel (for transparency).- Choose `none` if you only want to render audio.-### `parallelism?`+### `concurrency?`_optional_-A `number` specifying how many frames should be rendered in parallel or `null` to let Remotion decide based on the CPU of the host machine. Default is half of the CPU threads available.+A `number` specifying how many render processes should be started in parallel or `null` to let Remotion decide based on the CPU of the host machine. Default is half of the CPU threads available.++### ~~`parallelism?`~~++Renamed to `concurrency` in v3.2.17.### `scale?`diff --git a/packages/docs/docs/renderer/render-media.md b/packages/docs/docs/renderer/render-media.mdindex f81e23c76c..4e835e83a3 100644--- a/packages/docs/docs/renderer/render-media.md+++ b/packages/docs/docs/renderer/render-media.md@@ -47,12 +47,15 @@ _object - optional_An object of arbitrary shape that will be passed as [props to your composition](/docs/parametrized-rendering) and that can be retrieved using [`getInputProps()`](/docs/get-input-props).-### `parallelism`+### `concurrency?`-_number | null - optional_+_optional_++A `number` specifying how many render processes should be started in parallel or `null` to let Remotion decide based on the CPU of the host machine. Default is half of the CPU threads available.++### ~~`parallelism?`~~-How many threads should be used for rendering frames. By default `null`, which will use half of the threads that your CPU has.-Type `node -e "console.log(require('os').cpus().length)"` into your command line to find out how many threads your CPU has.+Renamed to `concurrency` in v3.2.17.### `crf`@@ -62,7 +65,7 @@ The constant rate factor, controlling the quality. See: [Controlling quality usi### `imageFormat`-_"jpeg" (default) | "png" |Â "none" - optional_+_"jpeg" (default) | "png" | "none" - optional_In which image format the frames should be rendered.diff --git a/packages/example/src/simulate-lambda.ts b/packages/example/src/simulate-lambda.tsindex 68d012a7c4..2e658c4004 100644--- a/packages/example/src/simulate-lambda.ts+++ b/packages/example/src/simulate-lambda.ts@@ -28,7 +28,7 @@ const start = async () => {outputLocation: path.join(filelistDir, 'out/there' + i + '.mkv'),serveUrl: bundled,frameRange: [i * framesPerLambda, (i + 1) * framesPerLambda - 1],- parallelism: 1,+ concurrency: 1,numberOfGifLoops: null,everyNthFrame: 1,verbose: false,diff --git a/packages/it-tests/src/ssr/cancel-after-success.test.ts b/packages/it-tests/src/ssr/cancel-after-success.test.tsindex 4a26ef644c..b2e2f90a0d 100644--- a/packages/it-tests/src/ssr/cancel-after-success.test.ts+++ b/packages/it-tests/src/ssr/cancel-after-success.test.ts@@ -16,7 +16,7 @@ test("Cancelling after success should not throw error", async () => {id: "react-svg",width: 1280,},- parallelism: 1,+ concurrency: 1,outputLocation,cancelSignal,});diff --git a/packages/it-tests/src/ssr/render-frames.test.ts b/packages/it-tests/src/ssr/render-frames.test.tsindex da4204f113..bb9ddd3d96 100644--- a/packages/it-tests/src/ssr/render-frames.test.ts+++ b/packages/it-tests/src/ssr/render-frames.test.ts@@ -40,7 +40,7 @@ test("Legacy SSR way of rendering videos should still work", async () => {inputProps: {},onFrameUpdate: () => undefined,webpackBundle: "https://gleaming-wisp-de5d2a.netlify.app/",- parallelism: null,+ concurrency: null,frameRange: [0, 10],outputDir: framesDir,onStart: () => undefined,diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.tsindex 0a506fe95c..631c1cb0e8 100644--- a/packages/lambda/src/functions/renderer.ts+++ b/packages/lambda/src/functions/renderer.ts@@ -113,7 +113,7 @@ const renderHandler = async (chunkTimingData.timings[renderedFrames] = Date.now() - start;},- parallelism: params.concurrencyPerLambda,+ concurrency: params.concurrencyPerLambda,onStart: () => {lambdaWriteFile({privacy: 'private',diff --git a/packages/renderer/src/render-frames.ts b/packages/renderer/src/render-frames.tsindex 712e2fbb56..6fe21e5d2b 100644--- a/packages/renderer/src/render-frames.ts+++ b/packages/renderer/src/render-frames.ts@@ -55,6 +55,17 @@ type ConfigOrComposition =composition: SmallTCompMetadata;};+type ConcurrencyOrParallelism =+ | {+ concurrency: number | null;+ }+ | {+ /**+ * @deprecated This field has been renamed to `concurrency`+ */+ parallelism: number | null;+ };+type RenderFramesOptions = {onStart: (data: OnStartData) => void;onFrameUpdate: (framesRendered: number, frameIndex: number) => void;@@ -62,7 +73,6 @@ type RenderFramesOptions = {inputProps: unknown;envVariables?: Record<string, string>;imageFormat: ImageFormat;- parallelism?: number | null;quality?: number;frameRange?: FrameRange | null;everyNthFrame?: number;@@ -85,6 +95,7 @@ type RenderFramesOptions = {downloadMap?: DownloadMap;muted?: boolean;} & ConfigOrComposition &+ ConcurrencyOrParallelism &ServeUrlOrWebpackBundle;const getComposition = (others: ConfigOrComposition) => {@@ -99,6 +110,18 @@ const getComposition = (others: ConfigOrComposition) => {return undefined;};+const getConcurrency = (others: ConcurrencyOrParallelism) => {+ if ('concurrency' in others) {+ return others.concurrency;+ }++ if ('parallelism' in others) {+ return others.parallelism;+ }++ return undefined;+};+const getPool = async (pages: Promise<Page>[]) => {const puppeteerPages = await Promise.all(pages);const pool = new Pool(puppeteerPages);@@ -124,7 +147,7 @@ const innerRenderFrames = ({composition,timeoutInMilliseconds,scale,- actualParallelism,+ actualConcurrency,everyNthFrame = 1,proxyPort,cancelSignal,@@ -135,7 +158,7 @@ const innerRenderFrames = ({pagesArray: Page[];serveUrl: string;composition: SmallTCompMetadata;- actualParallelism: number;+ actualConcurrency: number;onDownload: RenderMediaOnDownload;proxyPort: number;downloadMap: DownloadMap;@@ -164,7 +187,7 @@ const innerRenderFrames = ({const framesToRender = getFramesToRender(realFrameRange, everyNthFrame);const lastFrame = framesToRender[framesToRender.length - 1];- const pages = new Array(actualParallelism).fill(true).map(async () => {+ const pages = new Array(actualConcurrency).fill(true).map(async () => {const page = await puppeteerInstance.newPage();pagesArray.push(page);await page.setViewport({@@ -382,6 +405,7 @@ export const renderFrames = (options: RenderFramesOptions): Promise<RenderFramesOutput> => {const composition = getComposition(options);+ const concurrency = getConcurrency(options);if (!composition) {throw new Error(@@ -432,7 +456,7 @@ export const renderFrames = (const onDownload = options.onDownload ?? (() => () => undefined);- const actualParallelism = getActualConcurrency(options.parallelism ?? null);+ const actualConcurrency = getActualConcurrency(concurrency ?? null);const openedPages: Page[] = [];@@ -462,7 +486,7 @@ export const renderFrames = (]).then(([{serveUrl, closeServer, offthreadPort}, puppeteerInstance]) => {const {stopCycling} = cycleBrowserTabs(puppeteerInstance,- actualParallelism+ actualConcurrency);cleanup.push(stopCycling);@@ -475,7 +499,7 @@ export const renderFrames = (pagesArray: openedPages,serveUrl,composition,- actualParallelism,+ actualConcurrency,onDownload,proxyPort: offthreadPort,downloadMap,diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.tsindex 9c3c8d38e4..453373f2b2 100644--- a/packages/renderer/src/render-media.ts+++ b/packages/renderer/src/render-media.ts@@ -60,7 +60,6 @@ export type RenderMediaOptions = {codec: Codec;composition: SmallTCompMetadata;inputProps?: unknown;- parallelism?: number | null;crf?: number | null;imageFormat?: 'png' | 'jpeg' | 'none';ffmpegExecutable?: FfmpegExecutable;@@ -92,17 +91,40 @@ export type RenderMediaOptions = {downloadMap?: DownloadMap;muted?: boolean;enforceAudioTrack?: boolean;-} & ServeUrlOrWebpackBundle;+} & ServeUrlOrWebpackBundle &+ ConcurrencyOrParallelism;++type ConcurrencyOrParallelism =+ | {+ concurrency: number | null;+ }+ | {+ /**+ * @deprecated This field has been renamed to `concurrency`+ */+ parallelism: number | null;+ };type Await<T> = T extends PromiseLike<infer U> ? U : T;+const getConcurrency = (others: ConcurrencyOrParallelism) => {+ if ('concurrency' in others) {+ return others.concurrency;+ }++ if ('parallelism' in others) {+ return others.parallelism;+ }++ return null;+};+/**** @description Render a video from a composition* @link https://www.remotion.dev/docs/renderer/render-media*/export const renderMedia = ({- parallelism,proResProfile,crf,composition,@@ -145,6 +167,7 @@ export const renderMedia = ({: null;validateScale(scale);+ const concurrency = getConcurrency(options);const everyNthFrame = options.everyNthFrame ?? 1;const numberOfGifLoops = options.numberOfGifLoops ?? null;@@ -291,7 +314,7 @@ export const renderMedia = ({renderedFrames = frame;callUpdate();},- parallelism,+ concurrency,outputDir,onStart: (data) => {renderedFrames = 0;