🎥 Make videos programmatically with React
Add --fps and --duration CLI flags as AnyRemotionOption overrides
JonnyBurgerbbea1df6f057
diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.tsindex db7c313f29..1cb4c77a61 100644--- a/packages/cli/src/benchmark.ts+++ b/packages/cli/src/benchmark.ts@@ -211,6 +211,8 @@ export const benchmarkCommand = async (ffmpegOverride,height,width,+ fps,+ durationInFrames,concurrency: unparsedConcurrency,} = getCliOptions({isStill: false,@@ -491,6 +493,8 @@ export const benchmarkCommand = async (...composition,width: width ?? composition.width,height: height ?? composition.height,+ fps: fps ?? composition.fps,+ durationInFrames: durationInFrames ?? composition.durationInFrames,},crf: configFileCrf ?? null,envVariables,diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.tsindex 7a0ec0c115..2256a33a51 100644--- a/packages/cli/src/config/index.ts+++ b/packages/cli/src/config/index.ts@@ -117,6 +117,8 @@ const {ignoreCertificateErrorsOption,overrideHeightOption,overrideWidthOption,+ overrideFpsOption,+ overrideDurationOption,} = BrowserSafeApis.options;declare global {@@ -390,6 +392,14 @@ declare global {* Overrides the width of a composition*/readonly overrideWidth: (newWidth: number) => void;+ /**+ * Overrides the FPS of a composition+ */+ readonly overrideFps: (newFps: number) => void;+ /**+ * Overrides the duration in frames of a composition+ */+ readonly overrideDuration: (newDuration: number) => void;/*** Set the ProRes profile.* This method is only valid if the codec has been set to 'prores'.@@ -704,6 +714,8 @@ export const Config: FlatConfig = {setForSeamlessAacConcatenation: forSeamlessAacConcatenationOption.setConfig,overrideHeight: overrideHeightOption.setConfig,overrideWidth: overrideWidthOption.setConfig,+ overrideFps: overrideFpsOption.setConfig,+ overrideDuration: overrideDurationOption.setConfig,overrideFfmpegCommand: setFfmpegOverrideFunction,setAudioCodec: audioCodecOption.setConfig,setOffthreadVideoCacheSizeInBytes: (size) => {diff --git a/packages/cli/src/get-cli-options.ts b/packages/cli/src/get-cli-options.tsindex 8a65ada0ed..4109df4343 100644--- a/packages/cli/src/get-cli-options.ts+++ b/packages/cli/src/get-cli-options.ts@@ -70,6 +70,13 @@ export const getCliOptions = (options: {const width = BrowserSafeApis.options.overrideWidthOption.getValue({commandLine: parsedCli,}).value;+ const fps = BrowserSafeApis.options.overrideFpsOption.getValue({+ commandLine: parsedCli,+ }).value;+ const durationInFrames =+ BrowserSafeApis.options.overrideDurationOption.getValue({+ commandLine: parsedCli,+ }).value;RenderInternals.validateConcurrency({value: concurrency,@@ -91,5 +98,7 @@ export const getCliOptions = (options: {ffmpegOverride: ConfigInternals.getFfmpegOverrideFunction(),height,width,+ fps,+ durationInFrames,};};diff --git a/packages/cli/src/get-composition-with-dimension-override.ts b/packages/cli/src/get-composition-with-dimension-override.tsindex 89ed103933..5cd2adf621 100644--- a/packages/cli/src/get-composition-with-dimension-override.ts+++ b/packages/cli/src/get-composition-with-dimension-override.ts@@ -13,6 +13,8 @@ import {getCompositionId} from './get-composition-id';export const getCompositionWithDimensionOverride = async ({height,width,+ fps,+ durationInFrames,args,compositionIdFromUi,chromiumOptions,@@ -35,6 +37,8 @@ export const getCompositionWithDimensionOverride = async ({}: {height: number | null;width: number | null;+ fps: number | null;+ durationInFrames: number | null;args: (string | number)[];compositionIdFromUi: string | null;timeoutInMilliseconds: number;@@ -88,6 +92,9 @@ export const getCompositionWithDimensionOverride = async ({...returnValue.config,height: height ?? returnValue.config.height,width: width ?? returnValue.config.width,+ fps: fps ?? returnValue.config.fps,+ durationInFrames:+ durationInFrames ?? returnValue.config.durationInFrames,},};};diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.tsindex abafe1e448..a47faa45ce 100644--- a/packages/cli/src/parse-command-line.ts+++ b/packages/cli/src/parse-command-line.ts@@ -44,6 +44,8 @@ const {ignoreCertificateErrorsOption,overrideHeightOption,overrideWidthOption,+ overrideFpsOption,+ overrideDurationOption,} = BrowserSafeApis.options;export type CommandLineOptions = {@@ -113,6 +115,8 @@ export type CommandLineOptions = {muted: boolean;[overrideHeightOption.cliFlag]: TypeOfOption<typeof overrideHeightOption>;[overrideWidthOption.cliFlag]: TypeOfOption<typeof overrideWidthOption>;+ [overrideFpsOption.cliFlag]: TypeOfOption<typeof overrideFpsOption>;+ [overrideDurationOption.cliFlag]: TypeOfOption<typeof overrideDurationOption>;runs: number;concurrencies: string;[enforceAudioOption.cliFlag]: TypeOfOption<typeof enforceAudioOption>;diff --git a/packages/cli/src/render-flows/render.ts b/packages/cli/src/render-flows/render.tsindex 3f26e857bc..2aca245daf 100644--- a/packages/cli/src/render-flows/render.ts+++ b/packages/cli/src/render-flows/render.ts@@ -80,6 +80,8 @@ export const renderVideoFlow = async ({port,height,width,+ fps,+ durationInFrames,remainingArgs,compositionIdFromUi,entryPointReason,@@ -145,6 +147,8 @@ export const renderVideoFlow = async ({port: number | null;height: number | null;width: number | null;+ fps: number | null;+ durationInFrames: number | null;remainingArgs: (string | number)[];compositionIdFromUi: string | null;outputLocationFromUI: string | null;@@ -373,6 +377,8 @@ export const renderVideoFlow = async ({await getCompositionWithDimensionOverride({height,width,+ fps,+ durationInFrames,args: remainingArgs,compositionIdFromUi,browserExecutable,@@ -640,6 +646,8 @@ export const renderVideoFlow = async ({...config,width: width ?? config.width,height: height ?? config.height,+ fps: fps ?? config.fps,+ durationInFrames: durationInFrames ?? config.durationInFrames,},crf: crf ?? null,envVariables,diff --git a/packages/cli/src/render-flows/still.ts b/packages/cli/src/render-flows/still.tsindex 5e2699d1eb..7521da8cfd 100644--- a/packages/cli/src/render-flows/still.ts+++ b/packages/cli/src/render-flows/still.ts@@ -58,6 +58,9 @@ export const renderStillFlow = async ({chromiumOptions,envVariables,height,+ width,+ fps,+ durationInFrames,serializedInputPropsWithCustomSchema,overwrite,port,@@ -66,7 +69,6 @@ export const renderStillFlow = async ({jpegQuality,scale,stillFrame,- width,compositionIdFromUi,imageFormatFromUi,logLevel,@@ -104,6 +106,8 @@ export const renderStillFlow = async ({publicDir: string | null;height: number | null;width: number | null;+ fps: number | null;+ durationInFrames: number | null;compositionIdFromUi: string | null;imageFormatFromUi: StillImageFormat | null;logLevel: LogLevel;@@ -255,6 +259,8 @@ export const renderStillFlow = async ({await getCompositionWithDimensionOverride({height,width,+ fps,+ durationInFrames,args: remainingArgs,compositionIdFromUi,browserExecutable,diff --git a/packages/cli/src/render-queue/process-still.ts b/packages/cli/src/render-queue/process-still.tsindex f212fceef5..904e47ee74 100644--- a/packages/cli/src/render-queue/process-still.ts+++ b/packages/cli/src/render-queue/process-still.ts@@ -56,6 +56,9 @@ export const processStill = async ({entryPointReason: 'same as Studio',envVariables: job.envVariables,height: null,+ width: null,+ fps: null,+ durationInFrames: null,fullEntryPoint,serializedInputPropsWithCustomSchema:job.serializedInputPropsWithCustomSchema,@@ -67,7 +70,6 @@ export const processStill = async ({remainingArgs: [],scale: job.scale,stillFrame: job.frame,- width: null,compositionIdFromUi: job.compositionId,imageFormatFromUi: job.imageFormat,logLevel: job.logLevel,diff --git a/packages/cli/src/render-queue/process-video.ts b/packages/cli/src/render-queue/process-video.tsindex 0965f1e0b6..eda077a1cc 100644--- a/packages/cli/src/render-queue/process-video.ts+++ b/packages/cli/src/render-queue/process-video.ts@@ -59,6 +59,9 @@ export const processVideoJob = async ({entryPointReason: 'same as Studio',envVariables: job.envVariables,height: null,+ width: null,+ fps: null,+ durationInFrames: null,fullEntryPoint,serializedInputPropsWithCustomSchema:job.serializedInputPropsWithCustomSchema,@@ -69,7 +72,6 @@ export const processVideoJob = async ({jpegQuality: job.jpegQuality ?? undefined,remainingArgs: [],scale: job.scale,- width: null,compositionIdFromUi: job.compositionId,logLevel: job.logLevel,onProgress,diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsxindex 7bb0275663..940cccd588 100644--- a/packages/cli/src/render.tsx+++ b/packages/cli/src/render.tsx@@ -102,6 +102,8 @@ export const render = async (envVariables,height,width,+ fps,+ durationInFrames,ffmpegOverride,} = getCliOptions({isStill: false,@@ -253,6 +255,8 @@ export const render = async (port: getRendererPortFromConfigFileAndCliFlag(),height,width,+ fps,+ durationInFrames,remainingArgs,compositionIdFromUi: null,entryPointReason,diff --git a/packages/cli/src/still.ts b/packages/cli/src/still.tsindex da126daefa..ba51b8b1b2 100644--- a/packages/cli/src/still.ts+++ b/packages/cli/src/still.ts@@ -73,7 +73,7 @@ export const still = async (process.exit(1);}- const {envVariables, height, inputProps, stillFrame, width} = getCliOptions({+ const {envVariables, height, inputProps, stillFrame, width, fps, durationInFrames} = getCliOptions({isStill: true,logLevel,indent: false,@@ -160,6 +160,9 @@ export const still = async (chromiumOptions,envVariables,height,+ width,+ fps,+ durationInFrames,serializedInputPropsWithCustomSchema:NoReactInternals.serializeJSONWithSpecialTypes({data: inputProps,@@ -173,7 +176,6 @@ export const still = async (jpegQuality,scale,stillFrame,- width,compositionIdFromUi: null,imageFormatFromUi: null,logLevel,diff --git a/packages/cloudrun/src/api/render-media-on-cloudrun.ts b/packages/cloudrun/src/api/render-media-on-cloudrun.tsindex a14fbcbbd4..2fcecb5f69 100644--- a/packages/cloudrun/src/api/render-media-on-cloudrun.ts+++ b/packages/cloudrun/src/api/render-media-on-cloudrun.ts@@ -56,6 +56,8 @@ type InternalRenderMediaOnCloudrun = {chromiumOptions: ChromiumOptions | undefined;forceWidth: number | null;forceHeight?: number | null;+ forceFps?: number | null;+ forceDurationInFrames?: number | null;concurrency: number | string | null;preferLossless: boolean | undefined;indent: boolean;@@ -93,6 +95,8 @@ export type RenderMediaOnCloudrunInput = {chromiumOptions?: ChromiumOptions;forceWidth?: number | null;forceHeight?: number | null;+ forceFps?: number | null;+ forceDurationInFrames?: number | null;concurrency?: number | string | null;preferLossless?: boolean;downloadBehavior?: DownloadBehavior;@@ -135,6 +139,8 @@ const internalRenderMediaOnCloudrunRaw = async ({muted,forceWidth,forceHeight,+ forceFps,+ forceDurationInFrames,logLevel,delayRenderTimeoutInMilliseconds,concurrency,@@ -195,6 +201,8 @@ const internalRenderMediaOnCloudrunRaw = async ({outName,forceWidth,forceHeight,+ forceFps,+ forceDurationInFrames,type: 'media',logLevel: logLevel ?? 'info',delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds ?? null,@@ -334,6 +342,8 @@ export const renderMediaOnCloudrun = ({muted,forceWidth,forceHeight,+ forceFps,+ forceDurationInFrames,logLevel,delayRenderTimeoutInMilliseconds,concurrency,@@ -382,6 +392,8 @@ export const renderMediaOnCloudrun = ({muted: muted ?? false,forceWidth: forceWidth ?? null,forceHeight: forceHeight ?? null,+ forceFps: forceFps ?? null,+ forceDurationInFrames: forceDurationInFrames ?? null,logLevel: logLevel ?? 'info',delayRenderTimeoutInMilliseconds:delayRenderTimeoutInMilliseconds ?? BrowserSafeApis.DEFAULT_TIMEOUT,diff --git a/packages/cloudrun/src/api/render-still-on-cloudrun.ts b/packages/cloudrun/src/api/render-still-on-cloudrun.tsindex 80cc3be6de..f23c45d9c0 100644--- a/packages/cloudrun/src/api/render-still-on-cloudrun.ts+++ b/packages/cloudrun/src/api/render-still-on-cloudrun.ts@@ -43,6 +43,8 @@ type OptionalParameters = {chromiumOptions: ChromiumOptions;forceWidth: number | null;forceHeight: number | null;+ forceFps: number | null;+ forceDurationInFrames: number | null;indent: boolean;downloadBehavior: DownloadBehavior;renderIdOverride: z.infer<typeof CloudRunPayload>['renderIdOverride'];@@ -96,6 +98,8 @@ const internalRenderStillOnCloudRun = async ({scale,forceWidth,forceHeight,+ forceFps,+ forceDurationInFrames,logLevel,delayRenderTimeoutInMilliseconds,offthreadVideoCacheSizeInBytes,@@ -138,6 +142,8 @@ const internalRenderStillOnCloudRun = async ({scale,forceWidth,forceHeight,+ forceFps,+ forceDurationInFrames,frame,type: 'still',logLevel,@@ -239,6 +245,8 @@ export const renderStillOnCloudrun = (options: RenderStillOnCloudrunInput) => {forceBucketName: options.forceBucketName ?? null,forceHeight: options.forceHeight ?? null,forceWidth: options.forceWidth ?? null,+ forceFps: options.forceFps ?? null,+ forceDurationInFrames: options.forceDurationInFrames ?? null,frame: options.frame ?? 0,imageFormat: options.imageFormat,indent: options.indent ?? false,diff --git a/packages/cloudrun/src/cli/commands/render/index.ts b/packages/cloudrun/src/cli/commands/render/index.tsindex 7629074999..7972396fa9 100644--- a/packages/cloudrun/src/cli/commands/render/index.ts+++ b/packages/cloudrun/src/cli/commands/render/index.ts@@ -90,6 +90,8 @@ export const renderCommand = async (inputProps,height,width,+ fps,+ durationInFrames,} = CliInternals.getCliOptions({isStill: false,logLevel,@@ -191,13 +193,15 @@ export const renderCommand = async (chromiumOptions,envVariables,height,+ width,+ fps,+ durationInFrames,indent,port: ConfigInternals.getRendererPortFromConfigFileAndCliFlag(),puppeteerInstance: undefined,serveUrlOrWebpackUrl: serveUrl,timeoutInMilliseconds: puppeteerTimeout,logLevel,- width,server: await server,serializedInputPropsWithCustomSchema:NoReactInternals.serializeJSONWithSpecialTypes({@@ -355,6 +359,8 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}muted,forceWidth: width,forceHeight: height,+ forceFps: fps,+ forceDurationInFrames: durationInFrames,logLevel,delayRenderTimeoutInMilliseconds: puppeteerTimeout,// Special case: Should not use default local concurrency, or fromdiff --git a/packages/cloudrun/src/cli/commands/still.ts b/packages/cloudrun/src/cli/commands/still.tsindex cc152904e4..78198a7a4b 100644--- a/packages/cloudrun/src/cli/commands/still.ts+++ b/packages/cloudrun/src/cli/commands/still.ts@@ -51,6 +51,8 @@ export const stillCommand = async (stillFrame,height,width,+ fps,+ durationInFrames,} = CliInternals.getCliOptions({isStill: false,logLevel,@@ -155,6 +157,8 @@ export const stillCommand = async (timeoutInMilliseconds: puppeteerTimeout,height,width,+ fps,+ durationInFrames,server: await server,offthreadVideoCacheSizeInBytes,binariesDirectory,@@ -249,6 +253,8 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}scale,forceHeight: height,forceWidth: width,+ forceFps: fps,+ forceDurationInFrames: durationInFrames,forceBucketName,outName,logLevel,diff --git a/packages/cloudrun/src/functions/helpers/payloads.ts b/packages/cloudrun/src/functions/helpers/payloads.tsindex 0f0b416dbe..4a32ab986a 100644--- a/packages/cloudrun/src/functions/helpers/payloads.ts+++ b/packages/cloudrun/src/functions/helpers/payloads.ts@@ -37,6 +37,8 @@ export const CloudRunPayload = z.discriminatedUnion('type', [composition: z.string(),forceHeight: z.number().optional().nullable(),forceWidth: z.number().optional().nullable(),+ forceFps: z.number().optional().nullable(),+ forceDurationInFrames: z.number().optional().nullable(),codec,serializedInputPropsWithCustomSchema: z.string(),jpegQuality: z.number().nullable(),@@ -92,6 +94,8 @@ export const CloudRunPayload = z.discriminatedUnion('type', [composition: z.string(),forceHeight: z.number().optional().nullable(),forceWidth: z.number().optional().nullable(),+ forceFps: z.number().optional().nullable(),+ forceDurationInFrames: z.number().optional().nullable(),serializedInputPropsWithCustomSchema: z.string(),jpegQuality: z.number().optional(),imageFormat: stillImageFormat,diff --git a/packages/cloudrun/src/functions/render-media-single-thread.ts b/packages/cloudrun/src/functions/render-media-single-thread.tsindex ce7b801dd6..42538dee64 100644--- a/packages/cloudrun/src/functions/render-media-single-thread.ts+++ b/packages/cloudrun/src/functions/render-media-single-thread.ts@@ -139,6 +139,8 @@ export const renderMediaSingleThread = async (...composition,height: body.forceHeight ?? composition.height,width: body.forceWidth ?? composition.width,+ fps: body.forceFps ?? composition.fps,+ durationInFrames: body.forceDurationInFrames ?? composition.durationInFrames,},serveUrl: body.serveUrl,codec: body.codec,diff --git a/packages/cloudrun/src/functions/render-still-single-thread.ts b/packages/cloudrun/src/functions/render-still-single-thread.tsindex 3cc6374d31..c84864e790 100644--- a/packages/cloudrun/src/functions/render-still-single-thread.ts+++ b/packages/cloudrun/src/functions/render-still-single-thread.ts@@ -71,6 +71,8 @@ export const renderStillSingleThread = async (...composition,height: body.forceHeight ?? composition.height,width: body.forceWidth ?? composition.width,+ fps: body.forceFps ?? composition.fps,+ durationInFrames: body.forceDurationInFrames ?? composition.durationInFrames,},serveUrl: body.serveUrl,output: tempFilePath,diff --git a/packages/docs/docs/cli/render.mdx b/packages/docs/docs/cli/render.mdxindex ad2fb973bd..6168d78a7b 100644--- a/packages/docs/docs/cli/render.mdx+++ b/packages/docs/docs/cli/render.mdx@@ -39,6 +39,14 @@ Inline JSON string isn't supported on Windows shells because it removes the `"`<Options id="width" cli />+### `--fps`++<Options id="fps" cli />++### `--duration`++<Options id="duration" cli />+### `--concurrency`<Options id="concurrency" />diff --git a/packages/docs/docs/config.mdx b/packages/docs/docs/config.mdxindex 13c836dc8f..cb0394f61b 100644--- a/packages/docs/docs/config.mdx+++ b/packages/docs/docs/config.mdx@@ -632,6 +632,30 @@ Config.overrideWidth(900);The [command line flag](/docs/cli/render#--width) `--width` will take precedence over this option.+## `overrideFps()`++<Options id="fps" />++```ts twoslash title="remotion.config.ts"+import {Config} from '@remotion/cli/config';+// ---cut---+Config.overrideFps(25);+```++The [command line flag](/docs/cli/render#--fps) `--fps` will take precedence over this option.++## `overrideDuration()`++<Options id="duration" />++```ts twoslash title="remotion.config.ts"+import {Config} from '@remotion/cli/config';+// ---cut---+Config.overrideDuration(300);+```++The [command line flag](/docs/cli/render#--duration) `--duration` will take precedence over this option.+## `setCrf()`<AvailableFrom v="1.4.0" />The "Constant Rate Factor" (CRF) of the output. [Use this setting to tell FFmpeg how to trade off size and quality.](/docs/encoding#controlling-quality-using-the-crf-setting)diff --git a/packages/docs/docs/lambda/cli/render.mdx b/packages/docs/docs/lambda/cli/render.mdxindex 17c73bd607..8b9c394759 100644--- a/packages/docs/docs/lambda/cli/render.mdx+++ b/packages/docs/docs/lambda/cli/render.mdx@@ -232,6 +232,14 @@ Sets a webhook secret for the webhook (see above). [`renderMediaOnLambda() -> we<Options id="width" cli />+### `--fps`++<Options id="fps" cli />++### `--duration`++<Options id="duration" cli />+### `--function-name`<AvailableFrom v="3.3.38" />Specify the name of the function which should be used to invoke and orchestrate the render. You only need to pass it if there are multiple functions with different configurations.diff --git a/packages/lambda-client/src/make-lambda-payload.ts b/packages/lambda-client/src/make-lambda-payload.tsindex b57c5040b0..c98c2852ca 100644--- a/packages/lambda-client/src/make-lambda-payload.ts+++ b/packages/lambda-client/src/make-lambda-payload.ts@@ -78,6 +78,8 @@ export type InnerRenderMediaOnLambdaInput = {webhook: WebhookOption | null;forceWidth: number | null;forceHeight: number | null;+ forceFps: number | null;+ forceDurationInFrames: number | null;rendererFunctionName: string | null;forceBucketName: string | null;audioCodec: AudioCodec | null;@@ -124,6 +126,8 @@ export const makeLambdaRenderMediaPayload = async ({audioCodec,forceHeight,forceWidth,+ forceFps,+ forceDurationInFrames,webhook,videoBitrate,encodingMaxRate,@@ -213,6 +217,8 @@ export const makeLambdaRenderMediaPayload = async ({webhook: webhook ?? null,forceHeight: forceHeight ?? null,forceWidth: forceWidth ?? null,+ forceFps: forceFps ?? null,+ forceDurationInFrames: forceDurationInFrames ?? null,bucketName: bucketName ?? null,audioCodec: audioCodec ?? null,type: ServerlessRoutines.start,@@ -267,6 +273,8 @@ export const makeLambdaRenderStillPayload = async ({downloadBehavior,forceHeight,forceWidth,+ forceFps,+ forceDurationInFrames,forceBucketName,offthreadVideoCacheSizeInBytes,deleteAfter,@@ -322,6 +330,8 @@ export const makeLambdaRenderStillPayload = async ({version: VERSION,forceHeight,forceWidth,+ forceFps,+ forceDurationInFrames,bucketName: forceBucketName,offthreadVideoCacheSizeInBytes,deleteAfter,diff --git a/packages/lambda-client/src/render-media-on-lambda.ts b/packages/lambda-client/src/render-media-on-lambda.tsindex 37c6b00384..8d4232f4a3 100644--- a/packages/lambda-client/src/render-media-on-lambda.ts+++ b/packages/lambda-client/src/render-media-on-lambda.ts@@ -63,6 +63,8 @@ export type RenderMediaOnLambdaInput = {webhook?: WebhookOption | null;forceWidth?: number | null;forceHeight?: number | null;+ forceFps?: number | null;+ forceDurationInFrames?: number | null;rendererFunctionName?: string | null;forceBucketName?: string;audioCodec?: AudioCodec | null;@@ -174,6 +176,8 @@ export const renderMediaOnLambdaOptionalToRequired = (forceBucketName: options.forceBucketName ?? null,forceHeight: options.forceHeight ?? null,forceWidth: options.forceWidth ?? null,+ forceFps: options.forceFps ?? null,+ forceDurationInFrames: options.forceDurationInFrames ?? null,frameRange: options.frameRange ?? null,framesPerLambda: options.framesPerLambda ?? null,functionName: options.functionName,diff --git a/packages/lambda-client/src/render-still-on-lambda.ts b/packages/lambda-client/src/render-still-on-lambda.tsindex 49421559bd..e5a411ef7e 100644--- a/packages/lambda-client/src/render-still-on-lambda.ts+++ b/packages/lambda-client/src/render-still-on-lambda.ts@@ -42,6 +42,8 @@ type OptionalParameters = {downloadBehavior: DownloadBehavior;forceWidth: number | null;forceHeight: number | null;+ forceFps: number | null;+ forceDurationInFrames: number | null;forceBucketName: string | null;onInit: (data: {renderId: string;@@ -187,6 +189,8 @@ export function renderStillOnLambda(forceBucketName: input.forceBucketName ?? null,forceHeight: input.forceHeight ?? null,forceWidth: input.forceWidth ?? null,+ forceFps: input.forceFps ?? null,+ forceDurationInFrames: input.forceDurationInFrames ?? null,frame: input.frame ?? 0,functionName: input.functionName,imageFormat: input.imageFormat,diff --git a/packages/lambda-client/src/test/concurrency-payload.test.ts b/packages/lambda-client/src/test/concurrency-payload.test.tsindex 810a3d684d..cc720cd4e9 100644--- a/packages/lambda-client/src/test/concurrency-payload.test.ts+++ b/packages/lambda-client/src/test/concurrency-payload.test.ts@@ -40,6 +40,8 @@ test('Should include concurrency field in payload', async () => {webhook: null,forceHeight: null,forceWidth: null,+ forceFps: null,+ forceDurationInFrames: null,rendererFunctionName: null,forceBucketName: null,audioCodec: null,@@ -100,6 +102,8 @@ test('Should handle null concurrency', async () => {webhook: null,forceHeight: null,forceWidth: null,+ forceFps: null,+ forceDurationInFrames: null,rendererFunctionName: null,forceBucketName: null,audioCodec: null,diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.tsindex f0f5e58373..95c85126dc 100644--- a/packages/lambda/src/cli/commands/render/render.ts+++ b/packages/lambda/src/cli/commands/render/render.ts@@ -93,7 +93,7 @@ export const renderCommand = async ({const region = getAwsRegion();- const {envVariables, frameRange, inputProps, height, width} =+ const {envVariables, frameRange, inputProps, height, width, fps, durationInFrames} =CliInternals.getCliOptions({isStill: false,logLevel,@@ -248,6 +248,9 @@ export const renderCommand = async ({chromiumOptions,envVariables,height,+ width,+ fps,+ durationInFrames,indent,serializedInputPropsWithCustomSchema:NoReactInternals.serializeJSONWithSpecialTypes({@@ -260,7 +263,6 @@ export const renderCommand = async ({serveUrlOrWebpackUrl: serveUrl,timeoutInMilliseconds,logLevel,- width,server,offthreadVideoCacheSizeInBytes,offthreadVideoThreads,@@ -346,6 +348,8 @@ export const renderCommand = async ({encodingMaxRate,forceHeight: height,forceWidth: width,+ forceFps: fps,+ forceDurationInFrames: durationInFrames,webhook: parsedLambdaCli.webhook? {url: parsedLambdaCli.webhook,diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.tsindex 103d45670d..65d5dcee3d 100644--- a/packages/lambda/src/cli/commands/still.ts+++ b/packages/lambda/src/cli/commands/still.ts@@ -79,7 +79,7 @@ export const stillCommand = async ({quit(1);}- const {envVariables, inputProps, stillFrame, height, width} = getCliOptions({+ const {envVariables, inputProps, stillFrame, height, width, fps, durationInFrames} = getCliOptions({isStill: true,logLevel,indent: false,@@ -184,6 +184,8 @@ export const stillCommand = async ({timeoutInMilliseconds,height,width,+ fps,+ durationInFrames,server,offthreadVideoCacheSizeInBytes,offthreadVideoThreads,@@ -265,6 +267,8 @@ export const stillCommand = async ({scale,forceHeight: height,forceWidth: width,+ forceFps: fps,+ forceDurationInFrames: durationInFrames,onInit: ({cloudWatchLogs, lambdaInsightsUrl}) => {Log.verbose({indent: false, logLevel},diff --git a/packages/renderer/src/options/index.tsx b/packages/renderer/src/options/index.tsxindex c9eaaca295..a669ff7611 100644--- a/packages/renderer/src/options/index.tsx+++ b/packages/renderer/src/options/index.tsx@@ -45,6 +45,8 @@ import {offthreadVideoCacheSizeInBytesOption} from './offthreadvideo-cache-size'import {offthreadVideoThreadsOption} from './offthreadvideo-threads';import {onBrowserDownloadOption} from './on-browser-download';import type {AnyRemotionOption} from './option';+import {overrideDurationOption} from './override-duration';+import {overrideFpsOption} from './override-fps';import {overrideHeightOption} from './override-height';import {overrideWidthOption} from './override-width';import {overwriteOption} from './overwrite';@@ -137,6 +139,8 @@ export const allOptions = {videoImageFormatOption,overrideHeightOption,overrideWidthOption,+ overrideFpsOption,+ overrideDurationOption,};export type AvailableOptions = keyof typeof allOptions;diff --git a/packages/renderer/src/options/override-duration.tsx b/packages/renderer/src/options/override-duration.tsxnew file mode 100644index 0000000000..5544a779e8--- /dev/null+++ b/packages/renderer/src/options/override-duration.tsx@@ -0,0 +1,53 @@+import type {AnyRemotionOption} from './option';++let currentDuration: number | null = null;++const cliFlag = 'duration' as const;++export const overrideDurationOption = {+ name: 'Override Duration',+ cliFlag,+ description: () => (+ <>Overrides the duration in frames of the composition.</>+ ),+ ssrName: null,+ docLink: 'https://www.remotion.dev/docs/config#overrideduration',+ type: null as number | null,+ getValue: ({commandLine}) => {+ if (commandLine[cliFlag] !== undefined) {+ const value = commandLine[cliFlag] as number;+ if (typeof value !== 'number') {+ throw new TypeError(+ `--duration must be a number, got ${JSON.stringify(value)}`,+ );+ }++ return {+ source: 'cli',+ value,+ };+ }++ if (currentDuration !== null) {+ return {+ source: 'config',+ value: currentDuration,+ };+ }++ return {+ source: 'default',+ value: null,+ };+ },+ setConfig: (duration) => {+ if (typeof duration !== 'number') {+ throw new TypeError(+ `overrideDuration() must receive a number, got ${JSON.stringify(duration)}`,+ );+ }++ currentDuration = duration;+ },+ id: cliFlag,+} satisfies AnyRemotionOption<number | null>;diff --git a/packages/renderer/src/options/override-fps.tsx b/packages/renderer/src/options/override-fps.tsxnew file mode 100644index 0000000000..33e9c10ab5--- /dev/null+++ b/packages/renderer/src/options/override-fps.tsx@@ -0,0 +1,51 @@+import type {AnyRemotionOption} from './option';++let currentFps: number | null = null;++const cliFlag = 'fps' as const;++export const overrideFpsOption = {+ name: 'Override FPS',+ cliFlag,+ description: () => <>Overrides the frames per second of the composition.</>,+ ssrName: null,+ docLink: 'https://www.remotion.dev/docs/config#overridefps',+ type: null as number | null,+ getValue: ({commandLine}) => {+ if (commandLine[cliFlag] !== undefined) {+ const value = commandLine[cliFlag] as number;+ if (typeof value !== 'number') {+ throw new TypeError(+ `--fps must be a number, got ${JSON.stringify(value)}`,+ );+ }++ return {+ source: 'cli',+ value,+ };+ }++ if (currentFps !== null) {+ return {+ source: 'config',+ value: currentFps,+ };+ }++ return {+ source: 'default',+ value: null,+ };+ },+ setConfig: (fps) => {+ if (typeof fps !== 'number') {+ throw new TypeError(+ `overrideFps() must receive a number, got ${JSON.stringify(fps)}`,+ );+ }++ currentFps = fps;+ },+ id: cliFlag,+} satisfies AnyRemotionOption<number | null>;diff --git a/packages/serverless-client/src/constants.ts b/packages/serverless-client/src/constants.tsindex 42333ef1f2..b0ac559b9e 100644--- a/packages/serverless-client/src/constants.ts+++ b/packages/serverless-client/src/constants.ts@@ -149,6 +149,8 @@ export type ServerlessStartPayload<Provider extends CloudProvider> = {webhook: WebhookOption;forceHeight: number | null;forceWidth: number | null;+ forceFps: number | null;+ forceDurationInFrames: number | null;bucketName: string | null;offthreadVideoCacheSizeInBytes: number | null;offthreadVideoThreads: number | null;@@ -210,6 +212,8 @@ export type ServerlessPayloads<Provider extends CloudProvider> = {webhook: WebhookOption;forceHeight: number | null;forceWidth: number | null;+ forceFps: number | null;+ forceDurationInFrames: number | null;offthreadVideoCacheSizeInBytes: number | null;offthreadVideoThreads: number | null;mediaCacheSizeInBytes: number | null;@@ -295,6 +299,8 @@ export type ServerlessPayloads<Provider extends CloudProvider> = {version: string;forceHeight: number | null;forceWidth: number | null;+ forceFps: number | null;+ forceDurationInFrames: number | null;bucketName: string | null;offthreadVideoCacheSizeInBytes: number | null;offthreadVideoThreads: number | null;diff --git a/packages/serverless/src/handlers/launch.ts b/packages/serverless/src/handlers/launch.tsindex 10516c18d9..994f47dc2e 100644--- a/packages/serverless/src/handlers/launch.ts+++ b/packages/serverless/src/handlers/launch.ts@@ -145,6 +145,8 @@ const innerLaunchHandler = async <Provider extends CloudProvider>({port: null,forceHeight: params.forceHeight,forceWidth: params.forceWidth,+ forceFps: params.forceFps ?? null,+ forceDurationInFrames: params.forceDurationInFrames ?? null,logLevel: params.logLevel,server: undefined,offthreadVideoCacheSizeInBytes: params.offthreadVideoCacheSizeInBytes,diff --git a/packages/serverless/src/handlers/start.ts b/packages/serverless/src/handlers/start.tsindex 78bac25001..43cbb0acf1 100644--- a/packages/serverless/src/handlers/start.ts+++ b/packages/serverless/src/handlers/start.ts@@ -118,6 +118,8 @@ export const startHandler = async <Provider extends CloudProvider>({encodingMaxRate: params.encodingMaxRate,forceHeight: params.forceHeight,forceWidth: params.forceWidth,+ forceFps: params.forceFps ?? null,+ forceDurationInFrames: params.forceDurationInFrames ?? null,rendererFunctionName: params.rendererFunctionName,audioCodec: params.audioCodec,offthreadVideoCacheSizeInBytes: params.offthreadVideoCacheSizeInBytes,diff --git a/packages/serverless/src/handlers/still.ts b/packages/serverless/src/handlers/still.tsindex 3b0831a626..f32e759475 100644--- a/packages/serverless/src/handlers/still.ts+++ b/packages/serverless/src/handlers/still.ts@@ -171,6 +171,8 @@ const innerStillHandler = async <Provider extends CloudProvider>(port: null,forceHeight: params.forceHeight,forceWidth: params.forceWidth,+ forceFps: params.forceFps ?? null,+ forceDurationInFrames: params.forceDurationInFrames ?? null,logLevel: params.logLevel,server,offthreadVideoCacheSizeInBytes: params.offthreadVideoCacheSizeInBytes,diff --git a/packages/serverless/src/validate-composition.ts b/packages/serverless/src/validate-composition.tsindex 0553cfeff2..5d0334efdb 100644--- a/packages/serverless/src/validate-composition.ts+++ b/packages/serverless/src/validate-composition.ts@@ -29,6 +29,8 @@ type ValidateCompositionOptions<Provider extends CloudProvider> = {port: number | null;forceHeight: number | null;forceWidth: number | null;+ forceFps: number | null;+ forceDurationInFrames: number | null;logLevel: LogLevel;server: RemotionServer | undefined;offthreadVideoCacheSizeInBytes: number | null;@@ -50,6 +52,8 @@ export const validateComposition = async <Provider extends CloudProvider>({port,forceHeight,forceWidth,+ forceFps,+ forceDurationInFrames,logLevel,server,offthreadVideoCacheSizeInBytes,@@ -86,6 +90,8 @@ export const validateComposition = async <Provider extends CloudProvider>({...comp,height: forceHeight ?? comp.height,width: forceWidth ?? comp.width,+ fps: forceFps ?? comp.fps,+ durationInFrames: forceDurationInFrames ?? comp.durationInFrames,};const reason = `of the "<Composition />" component with the id "${composition}"`;