🎥 Make videos programmatically with React
new options management
Jonny Burgerbc10e6e99caa
diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.tsindex 67eca1ecfe..603b0750c8 100644--- a/packages/lambda/src/shared/constants.ts+++ b/packages/lambda/src/shared/constants.ts@@ -222,7 +222,9 @@ export type WebhookOption = Prettify<url: string;secret: string | null;} & Partial<- ToOptions<[typeof BrowserSafeApis.options.webhookCustomDataOption]>+ ToOptions<{+ customData: typeof BrowserSafeApis.options.webhookCustomDataOption;+ }>>)>;diff --git a/packages/renderer/src/options/index.tsx b/packages/renderer/src/options/index.tsxindex 01bc6e8217..027f2e5228 100644--- a/packages/renderer/src/options/index.tsx+++ b/packages/renderer/src/options/index.tsx@@ -11,7 +11,7 @@ import {folderExpiryOption} from './folder-expiry';import {glOption} from './gl';import {jpegQualityOption} from './jpeg-quality';import {muteOption} from './mute';-import {offthreadVideoCacheSizeInBytesOption} from './offthreadvideo-cache-size';+import {offthreadVideoCacheSizeInBytes} from './offthreadvideo-cache-size';import {scaleOption} from './scale';import {videoBitrate} from './video-bitrate';import {videoCodecOption} from './video-codec';@@ -26,7 +26,7 @@ export const allOptions = {enforceAudioOption,muteOption,videoCodecOption,- offthreadVideoCacheSizeInBytesOption,+ offthreadVideoCacheSizeInBytes,webhookCustomDataOption,colorSpaceOption,deleteAfterOption,diff --git a/packages/renderer/src/options/offthreadvideo-cache-size.tsx b/packages/renderer/src/options/offthreadvideo-cache-size.tsxindex c89a507ecf..12c38dcff6 100644--- a/packages/renderer/src/options/offthreadvideo-cache-size.tsx+++ b/packages/renderer/src/options/offthreadvideo-cache-size.tsx@@ -1,6 +1,6 @@import type {AnyRemotionOption} from './option';-export const offthreadVideoCacheSizeInBytesOption = {+export const offthreadVideoCacheSizeInBytes = {name: 'OffthreadVideo cache size',cliFlag: 'offthreadvideo-cache-size-in-bytes' as const,description: () => (diff --git a/packages/renderer/src/options/option.ts b/packages/renderer/src/options/option.tsindex dc7ef78353..0758054962 100644--- a/packages/renderer/src/options/option.ts+++ b/packages/renderer/src/options/option.ts@@ -12,6 +12,6 @@ export type RemotionOption<SsrName extends string, Type> = {export type AnyRemotionOption = RemotionOption<string, unknown>;-export type ToOptions<T extends readonly AnyRemotionOption[]> = {- [K in T[number]['ssrName']]: T[number]['type'];+export type ToOptions<T extends Record<string, AnyRemotionOption>> = {+ [K in keyof T]: T[K]['type'];};diff --git a/packages/renderer/src/options/options-map.ts b/packages/renderer/src/options/options-map.tsindex 94be2f0a4c..ccab33bf97 100644--- a/packages/renderer/src/options/options-map.ts+++ b/packages/renderer/src/options/options-map.ts@@ -1,14 +1,37 @@-import {offthreadVideoCacheSizeInBytesOption} from './offthreadvideo-cache-size';+import {offthreadVideoCacheSizeInBytes} from './offthreadvideo-cache-size';+import {videoBitrate} from './video-bitrate';export const optionsMap = {- renderMedia: [offthreadVideoCacheSizeInBytesOption],- renderStill: [offthreadVideoCacheSizeInBytesOption],- getCompositions: [offthreadVideoCacheSizeInBytesOption],- selectComposition: [offthreadVideoCacheSizeInBytesOption],- renderFrames: [offthreadVideoCacheSizeInBytesOption],- renderMediaOnLambda: [offthreadVideoCacheSizeInBytesOption],- renderStillOnLambda: [offthreadVideoCacheSizeInBytesOption],- getCompositionsOnLambda: [offthreadVideoCacheSizeInBytesOption],- renderMediaOnCloudRun: [offthreadVideoCacheSizeInBytesOption],- renderStillOnCloudRun: [offthreadVideoCacheSizeInBytesOption],+ renderMedia: {+ offthreadVideoCacheSizeInBytes,+ videoBitrate,+ },+ renderStill: {+ offthreadVideoCacheSizeInBytes,+ },+ getCompositions: {+ offthreadVideoCacheSizeInBytes,+ },+ selectComposition: {+ offthreadVideoCacheSizeInBytes,+ },+ renderFrames: {+ offthreadVideoCacheSizeInBytes,+ },+ renderMediaOnLambda: {+ offthreadVideoCacheSizeInBytes,+ videoBitrate,+ },+ renderStillOnLambda: {+ offthreadVideoCacheSizeInBytes,+ },+ getCompositionsOnLambda: {+ offthreadVideoCacheSizeInBytes,+ },+ renderMediaOnCloudRun: {+ offthreadVideoCacheSizeInBytes,+ },+ renderStillOnCloudRun: {+ offthreadVideoCacheSizeInBytes,+ },} as const;diff --git a/packages/renderer/src/options/video-bitrate.tsx b/packages/renderer/src/options/video-bitrate.tsxindex 505f1e21f8..a47f514348 100644--- a/packages/renderer/src/options/video-bitrate.tsx+++ b/packages/renderer/src/options/video-bitrate.tsx@@ -13,5 +13,5 @@ export const videoBitrate = {),ssrName: 'videoBitrate',docLink: 'https://www.remotion.dev/docs/renderer/render-media#videobitrate-',- type: '' as string,+ type: '' as string | null,} satisfies AnyRemotionOption;diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.tsindex a0b8d13bff..fdc5d090bb 100644--- a/packages/renderer/src/render-media.ts+++ b/packages/renderer/src/render-media.ts@@ -83,6 +83,8 @@ export type RenderMediaOnProgress = (progress: {stitchStage: StitchingState;}) => void;+type MoreRenderMediaOptions = ToOptions<typeof optionsMap.renderMedia>;+export type InternalRenderMediaOptions = {outputLocation: string | null;codec: Codec;@@ -128,9 +130,13 @@ export type InternalRenderMediaOptions = {serveUrl: string;concurrency: number | string | null;colorSpace: ColorSpace;-} & ToOptions<typeof optionsMap.renderMedia>;+} & MoreRenderMediaOptions;++type Prettify<T> = {+ [K in keyof T]: T[K];+} & {};-export type RenderMediaOptions = {+export type RenderMediaOptions = Prettify<{outputLocation?: string | null;codec: Codec;composition: VideoConfig;@@ -184,7 +190,7 @@ export type RenderMediaOptions = {logLevel?: LogLevel;offthreadVideoCacheSizeInBytes?: number | null;colorSpace?: ColorSpace;-};+}>;type Await<T> = T extends PromiseLike<infer U> ? U : T;