🎥 Make videos programmatically with React
Migrate `--concurrencies` CLI flag to option system
Jonny Burger7a661a0d9f70
diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.tsindex 3e0dd0c53a..c59c48d7e8 100644--- a/packages/cli/src/benchmark.ts+++ b/packages/cli/src/benchmark.ts@@ -76,8 +76,12 @@ const {runsOption,} = BrowserSafeApis.options;+const {benchmarkConcurrenciesOption} = BrowserSafeApis.options;+const getValidConcurrency = (cliConcurrency: number | string | null) => {- const {concurrencies} = parsedCli;+ const concurrencies = benchmarkConcurrenciesOption.getValue({+ commandLine: parsedCli,+ }).value;if (!concurrencies) {return [RenderInternals.resolveConcurrency(cliConcurrency)];diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.tsindex 26f1f072df..076266dd16 100644--- a/packages/cli/src/config/index.ts+++ b/packages/cli/src/config/index.ts@@ -50,6 +50,7 @@ import {getWebpackPolling} from './webpack-poll';export type {Concurrency, WebpackConfiguration, WebpackOverrideFn};const {+ benchmarkConcurrenciesOption,concurrencyOption,offthreadVideoCacheSizeInBytesOption,x264Option,@@ -613,6 +614,12 @@ type FlatConfig = RemotionConfigObject &* Default: 3*/setBenchmarkRuns: (runs: number) => void;+ /**+ * Set which concurrency values should be used during a benchmark.+ * Pass a comma-separated string of numbers, e.g. "1,4,8".+ * Default: null (uses the --concurrency value)+ */+ setBenchmarkConcurrencies: (concurrencies: string | null) => void;/*** @deprecated 'The config format has changed. Change `Config.Bundling.*()` calls to `Config.*()` in your config file.'*/@@ -763,6 +770,7 @@ export const Config: FlatConfig = {setIPv4: ipv4Option.setConfig,setBundleOutDir: outDirOption.setConfig,setBenchmarkRuns: runsOption.setConfig,+ setBenchmarkConcurrencies: benchmarkConcurrenciesOption.setConfig,};export const ConfigInternals = {diff --git a/packages/cli/src/parsed-cli.ts b/packages/cli/src/parsed-cli.tsindex 08085e1474..a7983f6831 100644--- a/packages/cli/src/parsed-cli.ts+++ b/packages/cli/src/parsed-cli.ts@@ -8,6 +8,7 @@ import {BrowserSafeApis} from '@remotion/renderer/client';import minimist from 'minimist';const {+ benchmarkConcurrenciesOption,beepOnFinishOption,colorSpaceOption,concurrencyOption,@@ -153,7 +154,9 @@ export type CommandLineOptions = {[overrideFpsOption.cliFlag]: TypeOfOption<typeof overrideFpsOption>;[overrideDurationOption.cliFlag]: TypeOfOption<typeof overrideDurationOption>;[runsOption.cliFlag]: TypeOfOption<typeof runsOption>;- concurrencies: string;+ [benchmarkConcurrenciesOption.cliFlag]: TypeOfOption<+ typeof benchmarkConcurrenciesOption+ >;[enforceAudioOption.cliFlag]: TypeOfOption<typeof enforceAudioOption>;[glOption.cliFlag]: TypeOfOption<typeof glOption>;[packageManagerOption.cliFlag]: TypeOfOption<typeof packageManagerOption>;diff --git a/packages/docs/docs/cli/benchmark.mdx b/packages/docs/docs/cli/benchmark.mdxindex beb9287199..3e1d6b9f3c 100644--- a/packages/docs/docs/cli/benchmark.mdx+++ b/packages/docs/docs/cli/benchmark.mdx@@ -25,7 +25,7 @@ If `composition-ids` is not passed, Remotion will let you select compositions fr### `--concurrencies`-You can specify which concurrency value should be used while rendering the video. Multiple concurrency values can be passed separated by comma. Learn more about [concurrency](/docs/terminology/concurrency)+<Options id="concurrencies" />### `--codec`diff --git a/packages/docs/docs/config.mdx b/packages/docs/docs/config.mdxindex 18bf5fdb6e..1b3205423b 100644--- a/packages/docs/docs/config.mdx+++ b/packages/docs/docs/config.mdx@@ -111,6 +111,18 @@ Config.setBenchmarkRuns(5);The [command line flag](/docs/cli/benchmark#--runs) `--runs` will take precedence over this option.+## `setBenchmarkConcurrencies()`++<Options id="concurrencies" />++```ts twoslash title="remotion.config.ts"+import {Config} from '@remotion/cli/config';+// ---cut---+Config.setBenchmarkConcurrencies('1,4,8');+```++The [command line flag](/docs/cli/benchmark#--concurrencies) `--concurrencies` will take precedence over this option.+## `setEntryPoint()`<AvailableFrom v="3.2.40" />Sets the Remotion [entry point](/docs/terminology/entry-point), you don't have to specify it for CLI commands.diff --git a/packages/renderer/src/options/benchmark-concurrencies.tsx b/packages/renderer/src/options/benchmark-concurrencies.tsxnew file mode 100644index 0000000000..bf1fc8b4f4--- /dev/null+++ b/packages/renderer/src/options/benchmark-concurrencies.tsx@@ -0,0 +1,36 @@+import type {AnyRemotionOption} from './option';++let currentConcurrencies: string | null = null;++const cliFlag = 'concurrencies' as const;++export const benchmarkConcurrenciesOption = {+ name: 'Benchmark concurrencies',+ cliFlag,+ description: () => (+ <>+ Specify which concurrency values should be used while benchmarking. Multiple+ values can be passed separated by comma. Learn more about{' '}+ <a href="https://remotion.dev/docs/terminology/concurrency">concurrency</a>+ .+ </>+ ),+ ssrName: null,+ docLink: 'https://www.remotion.dev/docs/cli/benchmark#--concurrencies',+ type: null as string | null,+ getValue: ({commandLine}) => {+ if (commandLine[cliFlag] !== undefined) {+ return {value: commandLine[cliFlag] as string, source: 'cli'};+ }++ if (currentConcurrencies !== null) {+ return {value: currentConcurrencies, source: 'config'};+ }++ return {value: null, source: 'default'};+ },+ setConfig: (value: string | null) => {+ currentConcurrencies = value;+ },+ id: cliFlag,+} satisfies AnyRemotionOption<string | null>;diff --git a/packages/renderer/src/options/index.tsx b/packages/renderer/src/options/index.tsxindex 8b9453cae7..d8cddf15ac 100644--- a/packages/renderer/src/options/index.tsx+++ b/packages/renderer/src/options/index.tsx@@ -1,6 +1,7 @@import {apiKeyOption} from './api-key';import {askAIOption} from './ask-ai';import {audioBitrateOption} from './audio-bitrate';+import {benchmarkConcurrenciesOption} from './benchmark-concurrencies';import {audioCodecOption} from './audio-codec';import {beepOnFinishOption} from './beep-on-finish';import {binariesDirectoryOption} from './binaries-directory';@@ -89,6 +90,7 @@ import {x264Option} from './x264-preset';export const allOptions = {audioCodecOption,+ benchmarkConcurrenciesOption,browserExecutableOption,concurrencyOption,scaleOption,