Skip to content

🎥 Make videos programmatically with React

refactor props

Jonny Burger63db1be0dde2
diff --git a/packages/bundler/src/renderEntry.tsx b/packages/bundler/src/renderEntry.tsx
index f4945e1569..8130384832 100644
--- a/packages/bundler/src/renderEntry.tsx
+++ b/packages/bundler/src/renderEntry.tsx
@@ -68,7 +68,9 @@ const GetVideo: React.FC<{state: BundleState}> = ({state}) => {
compositions.setCurrentComposition(foundComposition?.id ?? null);
compositions.setCurrentCompositionMetadata({
- props: state.props,
+ props: Internals.deserializeJSONWithCustomFields(
+ state.serializedResolvedPropsWithSchema
+ ),
durationInFrames: state.compositionDurationInFrames,
fps: state.compositionFps,
height: state.compositionHeight,
diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.ts
index b717058b40..1ba75944bf 100644
--- a/packages/cli/src/benchmark.ts
+++ b/packages/cli/src/benchmark.ts
@@ -330,6 +330,9 @@ export const benchmarkCommand = async (
onStart: () => undefined,
preferLossless: false,
server: undefined,
+ serializedResolvedPropsWithCustomSchema: JSON.stringify(
+ composition.props
+ ),
},
(run, progress) => {
benchmarkProgress.update(
diff --git a/packages/cli/src/codemods/stringify-with-path.ts b/packages/cli/src/codemods/stringify-with-path.ts
index 6d60808857..9cb3aeb3a3 100644
--- a/packages/cli/src/codemods/stringify-with-path.ts
+++ b/packages/cli/src/codemods/stringify-with-path.ts
@@ -1,5 +1,5 @@
+import {Internals} from 'remotion';
import type {EnumPath} from '../editor/components/RenderModal/SchemaEditor/extract-enum-json-paths';
-import {FILE_TOKEN} from '../editor/components/RenderModal/SchemaEditor/input-props-serialization';
const doesMatchPath = (path1: EnumPath, enumPaths: EnumPath[]) => {
return enumPaths.some((p) =>
@@ -36,9 +36,9 @@ export const stringifyDefaultProps = ({
return `${item}__ADD_AS_CONST__`;
}
- if (typeof item === 'string' && item.startsWith(FILE_TOKEN)) {
+ if (typeof item === 'string' && item.startsWith(Internals.FILE_TOKEN)) {
return `__REMOVEQUOTE____WRAP_IN_STATIC_FILE_START__${decodeURIComponent(
- item.replace(FILE_TOKEN, '')
+ item.replace(Internals.FILE_TOKEN, '')
)}__WRAP_IN_STATIC_FILE_END____REMOVEQUOTE__`;
}
diff --git a/packages/cli/src/editor/components/RenderModal/DataEditor.tsx b/packages/cli/src/editor/components/RenderModal/DataEditor.tsx
index c2f6b24436..26d3f21820 100644
--- a/packages/cli/src/editor/components/RenderModal/DataEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/DataEditor.tsx
@@ -5,7 +5,7 @@ import React, {
useMemo,
useState,
} from 'react';
-import type {AnyComposition} from 'remotion';
+import type {AnyComposition, SerializedJSONWithCustomFields} from 'remotion';
import {getInputProps, Internals} from 'remotion';
import type {z} from 'zod';
import {subscribeToEvent} from '../../../event-source';
@@ -28,8 +28,6 @@ import {
} from './get-render-modal-warnings';
import {RenderModalJSONPropsEditor} from './RenderModalJSONPropsEditor';
import {extractEnumJsonPaths} from './SchemaEditor/extract-enum-json-paths';
-import type {SerializedJSONWithCustomFields} from './SchemaEditor/input-props-serialization';
-import {serializeJSONWithDate} from './SchemaEditor/input-props-serialization';
import {SchemaEditor} from './SchemaEditor/SchemaEditor';
import {
NoDefaultProps,
@@ -140,7 +138,7 @@ export const DataEditor: React.FC<{
}
const value = inputProps;
- return serializeJSONWithDate({
+ return Internals.serializeJSONWithDate({
data: value,
indent: 2,
staticBase: window.remotion_staticBase,
diff --git a/packages/cli/src/editor/components/RenderModal/RenderModalJSONPropsEditor.tsx b/packages/cli/src/editor/components/RenderModal/RenderModalJSONPropsEditor.tsx
index 33f07d2de9..2484bab35a 100644
--- a/packages/cli/src/editor/components/RenderModal/RenderModalJSONPropsEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/RenderModalJSONPropsEditor.tsx
@@ -7,9 +7,9 @@ import {Flex, Row, Spacing} from '../layout';
import {RemTextarea} from '../NewComposition/RemTextarea';
import {ValidationMessage} from '../NewComposition/ValidationMessage';
import type {State} from './DataEditor';
-import type {SerializedJSONWithCustomFields} from './SchemaEditor/input-props-serialization';
-import {deserializeJSONWithCustomFields} from './SchemaEditor/input-props-serialization';
import {ZodErrorMessages} from './SchemaEditor/ZodErrorMessages';
+import type {SerializedJSONWithCustomFields} from 'remotion';
+import {Internals} from 'remotion';
const style: React.CSSProperties = {
fontFamily: 'monospace',
@@ -25,7 +25,7 @@ const scrollable: React.CSSProperties = {
const parseJSON = (str: string, schema: z.ZodTypeAny): State => {
try {
- const value = deserializeJSONWithCustomFields(str);
+ const value = Internals.deserializeJSONWithCustomFields(str);
const zodValidation = schema.safeParse(value);
return {str, value, validJSON: true, zodValidation};
} catch (e) {
diff --git a/packages/cli/src/editor/components/RenderQueue/actions.ts b/packages/cli/src/editor/components/RenderQueue/actions.ts
index c2e924127f..b35d2d93ac 100644
--- a/packages/cli/src/editor/components/RenderQueue/actions.ts
+++ b/packages/cli/src/editor/components/RenderQueue/actions.ts
@@ -13,7 +13,7 @@ import type {
} from '../../../preview-server/render-queue/job';
import type {RequiredChromiumOptions} from '../../../required-chromium-options';
import type {EnumPath} from '../RenderModal/SchemaEditor/extract-enum-json-paths';
-import {serializeJSONWithDate} from '../RenderModal/SchemaEditor/input-props-serialization';
+import {Internals} from 'remotion';
const callApi = <Endpoint extends keyof ApiRoutes>(
endpoint: Endpoint,
@@ -86,7 +86,7 @@ export const addStillRenderJob = ({
chromiumOptions,
delayRenderTimeout,
envVariables,
- serializedInputPropsWithCustomSchema: serializeJSONWithDate({
+ serializedInputPropsWithCustomSchema: Internals.serializeJSONWithDate({
data: inputProps,
staticBase: window.remotion_staticBase,
indent: undefined,
@@ -173,7 +173,7 @@ export const addVideoRenderJob = ({
disallowParallelEncoding,
chromiumOptions,
envVariables,
- serializedInputPropsWithCustomSchema: serializeJSONWithDate({
+ serializedInputPropsWithCustomSchema: Internals.serializeJSONWithDate({
data: inputProps,
staticBase: window.remotion_staticBase,
indent: undefined,
@@ -235,7 +235,7 @@ export const updateDefaultProps = (
) => {
return callApi('/api/update-default-props', {
compositionId,
- defaultProps: serializeJSONWithDate({
+ defaultProps: Internals.serializeJSONWithDate({
data: defaultProps,
indent: undefined,
staticBase: window.remotion_staticBase,
diff --git a/packages/cli/src/preview-server/render-queue/make-retry-payload.ts b/packages/cli/src/preview-server/render-queue/make-retry-payload.ts
index bfdc709f9c..920a6bee0d 100644
--- a/packages/cli/src/preview-server/render-queue/make-retry-payload.ts
+++ b/packages/cli/src/preview-server/render-queue/make-retry-payload.ts
@@ -7,7 +7,7 @@ import type {
import type {RenderModalState} from '../../editor/state/modals';
import {getDefaultCodecs} from './get-default-video-contexts';
import type {RenderJob} from './job';
-import {deserializeJSONWithCustomFields} from '../../editor/components/RenderModal/SchemaEditor/input-props-serialization';
+import {Internals} from 'remotion';
export const makeRetryPayload = (job: RenderJob): RenderModalState => {
const defaults = window.remotion_renderDefaults;
@@ -53,7 +53,7 @@ export const makeRetryPayload = (job: RenderJob): RenderModalState => {
initialHeadless: job.chromiumOptions.headless,
initialIgnoreCertificateErrors:
job.chromiumOptions.ignoreCertificateErrors,
- defaultProps: deserializeJSONWithCustomFields(
+ defaultProps: Internals.deserializeJSONWithCustomFields(
job.serializedInputPropsWithCustomSchema
),
inFrameMark: null,
@@ -100,7 +100,7 @@ export const makeRetryPayload = (job: RenderJob): RenderModalState => {
initialHeadless: job.chromiumOptions.headless,
initialIgnoreCertificateErrors:
job.chromiumOptions.ignoreCertificateErrors,
- defaultProps: deserializeJSONWithCustomFields(
+ defaultProps: Internals.deserializeJSONWithCustomFields(
job.serializedInputPropsWithCustomSchema
),
inFrameMark: job.startFrame,
diff --git a/packages/cli/src/preview-server/routes/update-default-props.ts b/packages/cli/src/preview-server/routes/update-default-props.ts
index 12bd205f56..8f6355929f 100644
--- a/packages/cli/src/preview-server/routes/update-default-props.ts
+++ b/packages/cli/src/preview-server/routes/update-default-props.ts
@@ -1,6 +1,5 @@
import {readFileSync, writeFileSync} from 'node:fs';
import {updateDefaultProps} from '../../codemods/update-default-props';
-import {deserializeJSONWithCustomFields} from '../../editor/components/RenderModal/SchemaEditor/input-props-serialization';
import type {ApiHandler} from '../api-types';
import {getProjectInfo} from '../project-info';
import type {
@@ -8,6 +7,7 @@ import type {
UpdateDefaultPropsResponse,
} from '../render-queue/job';
import {checkIfTypeScriptFile} from './can-update-default-props';
+import {Internals} from 'remotion';
export const updateDefaultPropsHandler: ApiHandler<
UpdateDefaultPropsRequest,
@@ -24,7 +24,7 @@ export const updateDefaultPropsHandler: ApiHandler<
const updated = await updateDefaultProps({
compositionId,
input: readFileSync(projectInfo.videoFile, 'utf-8'),
- newDefaultProps: deserializeJSONWithCustomFields(defaultProps),
+ newDefaultProps: Internals.deserializeJSONWithCustomFields(defaultProps),
enumPaths,
});
diff --git a/packages/cli/src/render-flows/render.ts b/packages/cli/src/render-flows/render.ts
index 8bec411ddf..42072020a8 100644
--- a/packages/cli/src/render-flows/render.ts
+++ b/packages/cli/src/render-flows/render.ts
@@ -394,6 +394,7 @@ export const renderVideoFlow = async ({
onBrowserLog: null,
onFrameBuffer: null,
logLevel,
+ serializedResolvedPropsWithCustomSchema: JSON.stringify(config.props),
});
updateRenderProgress(true);
@@ -464,6 +465,7 @@ export const renderVideoFlow = async ({
disallowParallelEncoding,
onBrowserLog: null,
onStart: () => undefined,
+ serializedResolvedPropsWithCustomSchema: JSON.stringify(config.props),
});
updateRenderProgress(true);
diff --git a/packages/cli/src/render-flows/still.ts b/packages/cli/src/render-flows/still.ts
index df74585e6b..9c8260130b 100644
--- a/packages/cli/src/render-flows/still.ts
+++ b/packages/cli/src/render-flows/still.ts
@@ -298,6 +298,7 @@ export const renderStillFlow = async ({
indent: indentOutput,
onBrowserLog: null,
logLevel,
+ serializedResolvedPropsWithCustomSchema: JSON.stringify(config.props),
});
aggregate.rendering = {
diff --git a/packages/cli/src/test/json-serialization.test.ts b/packages/cli/src/test/json-serialization.test.ts
index 4b039d2a29..09d37ce140 100644
--- a/packages/cli/src/test/json-serialization.test.ts
+++ b/packages/cli/src/test/json-serialization.test.ts
@@ -1,14 +1,13 @@
+import {Internals} from 'remotion';
import {expect, test} from 'vitest';
-import {
- deserializeJSONWithCustomFields,
- serializeJSONWithDate,
-} from '../editor/components/RenderModal/SchemaEditor/input-props-serialization';
+
+// TODO: move this to core library
test('date serialization', () => {
const date = {data: new Date(), hi: 'there'};
const {serializedString, customDateUsed, customFileUsed} =
- serializeJSONWithDate({
+ Internals.serializeJSONWithDate({
data: date,
indent: 2,
staticBase: '/static',
@@ -16,24 +15,26 @@ test('date serialization', () => {
expect(customDateUsed).toEqual(true);
expect(customFileUsed).toEqual(false);
- const deserialized = deserializeJSONWithCustomFields(serializedString);
+ const deserialized =
+ Internals.deserializeJSONWithCustomFields(serializedString);
expect(deserialized.data).toBeInstanceOf(Date);
});
test('No date used', () => {
- const {customDateUsed, customFileUsed, mapUsed} = serializeJSONWithDate({
- data: {a: 'hi'},
- indent: 2,
- staticBase: '/static',
- });
+ const {customDateUsed, customFileUsed, mapUsed} =
+ Internals.serializeJSONWithDate({
+ data: {a: 'hi'},
+ indent: 2,
+ staticBase: '/static',
+ });
expect(customDateUsed).toEqual(false);
expect(customFileUsed).toEqual(false);
expect(mapUsed).toEqual(false);
});
test('Map used', () => {
- const {mapUsed} = serializeJSONWithDate({
+ const {mapUsed} = Internals.serializeJSONWithDate({
data: {a: 'hi', map: new Map()},
indent: 2,
staticBase: '/static',
diff --git a/packages/core/src/config/input-props.ts b/packages/core/src/config/input-props.ts
index a55a2308b9..83a6d287ef 100644
--- a/packages/core/src/config/input-props.ts
+++ b/packages/core/src/config/input-props.ts
@@ -1,4 +1,5 @@
import {getRemotionEnvironment} from '../get-environment.js';
+import {deserializeJSONWithCustomFields} from '../input-props-serialization.js';
let didWarnSSRImport = false;
@@ -35,6 +36,6 @@ export const getInputProps = () => {
return {};
}
- const parsed = JSON.parse(param);
+ const parsed = deserializeJSONWithCustomFields(param);
return parsed;
};
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 00c4b79ba8..6160e86417 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -52,7 +52,7 @@ export type BundleState =
| {
type: 'composition';
compositionName: string;
- props: Record<string, unknown>;
+ serializedResolvedPropsWithSchema: string;
compositionHeight: number;
compositionDurationInFrames: number;
compositionWidth: number;
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/input-props-serialization.ts b/packages/core/src/input-props-serialization.ts
similarity index 100%
rename from packages/cli/src/editor/components/RenderModal/SchemaEditor/input-props-serialization.ts
rename to packages/core/src/input-props-serialization.ts
diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.ts
index ad5aae5552..e753b21ed0 100644
--- a/packages/core/src/internals.ts
+++ b/packages/core/src/internals.ts
@@ -29,6 +29,12 @@ import {
getPreviewDomElement,
REMOTION_STUDIO_CONTAINER_ELEMENT,
} from './get-preview-dom-element.js';
+import type {SerializedJSONWithCustomFields} from './input-props-serialization.js';
+import {
+ deserializeJSONWithCustomFields,
+ FILE_TOKEN,
+ serializeJSONWithDate,
+} from './input-props-serialization.js';
import {processColor} from './interpolate-colors.js';
import {IsPlayerContextProvider, useIsPlayer} from './is-player.js';
import {NonceContext} from './nonce.js';
@@ -142,6 +148,9 @@ export const Internals = {
bundleName: 'bundle.js',
persistCurrentFrame,
useTimelineSetFrame,
+ serializeJSONWithDate,
+ deserializeJSONWithCustomFields,
+ FILE_TOKEN,
} as const;
export type {
@@ -157,4 +166,5 @@ export type {
MediaVolumeContextValue,
SetMediaVolumeContextValue,
RemotionEnvironment,
+ SerializedJSONWithCustomFields,
};
diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.ts
index 6079f8d22d..1e8a37b7c2 100644
--- a/packages/lambda/src/functions/launch.ts
+++ b/packages/lambda/src/functions/launch.ts
@@ -256,32 +256,16 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {
const reqSend = timer('sending off requests');
const serializedResolved = serializeOrThrow(comp.props, 'resolved-props');
- const serializedDefault = serializeOrThrow(
- comp.defaultProps,
- 'default-props'
- );
- const needsToUpload = getNeedsToUpload(
- 'video-or-audio',
- serializedResolved + serializedDefault
- );
+ const needsToUpload = getNeedsToUpload('video-or-audio', serializedResolved);
- const [serializedResolvedProps, serializedDefaultProps] = await Promise.all([
- compressInputProps({
- propsType: 'resolved-props',
- region: getCurrentRegionInFunction(),
- stringifiedInputProps: serializedResolved,
- userSpecifiedBucketName: params.bucketName,
- needsToUpload,
- }),
- compressInputProps({
- propsType: 'default-props',
- region: getCurrentRegionInFunction(),
- stringifiedInputProps: serializedDefault,
- userSpecifiedBucketName: params.bucketName,
- needsToUpload,
- }),
- ]);
+ const serializedResolvedProps = await compressInputProps({
+ propsType: 'resolved-props',
+ region: getCurrentRegionInFunction(),
+ stringifiedInputProps: serializedResolved,
+ userSpecifiedBucketName: params.bucketName,
+ needsToUpload,
+ });
const lambdaPayloads = chunks.map((chunkPayload) => {
const payload: LambdaPayload = {
@@ -320,7 +304,6 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {
version: VERSION,
},
resolvedProps: serializedResolvedProps,
- defaultProps: serializedDefaultProps,
};
return payload;
});
diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.ts
index c52beefee2..52466e8408 100644
--- a/packages/lambda/src/functions/renderer.ts
+++ b/packages/lambda/src/functions/renderer.ts
@@ -63,14 +63,6 @@ const renderHandler = async (
propsType: 'resolved-props',
});
- const defaultPropsPromise = decompressInputProps({
- bucketName: params.bucketName,
- expectedBucketOwner: options.expectedBucketOwner,
- region: getCurrentRegionInFunction(),
- serialized: params.defaultProps,
- propsType: 'default-props',
- });
-
const browserInstance = await getBrowserInstance(
params.logLevel,
false,
@@ -118,9 +110,8 @@ const renderHandler = async (
const downloads: Record<string, number> = {};
- const inputProps = await inputPropsPromise;
const resolvedProps = await resolvedPropsPromise;
- const defaultProps = await defaultPropsPromise;
+ const serializedInputPropsWithCustomSchema = await inputPropsPromise;
await new Promise<void>((resolve, reject) => {
RenderInternals.internalRenderMedia({
@@ -130,11 +121,9 @@ const renderHandler = async (
fps: params.fps,
height: params.height,
width: params.width,
- props: resolvedProps,
- defaultProps,
},
imageFormat: params.imageFormat,
- serializedInputPropsWithCustomSchema: inputProps,
+ serializedInputPropsWithCustomSchema,
frameRange: params.frameRange,
onProgress: ({renderedFrames, encodedFrames, stitchStage}) => {
if (
@@ -242,6 +231,7 @@ const renderHandler = async (
indent: false,
onCtrlCExit: () => undefined,
server: undefined,
+ serializedResolvedPropsWithCustomSchema: resolvedProps,
})
.then(({slowestFrames}) => {
console.log(`Slowest frames:`);
diff --git a/packages/lambda/src/functions/still.ts b/packages/lambda/src/functions/still.ts
index 5b1f78ae6e..c4bc0909e6 100644
--- a/packages/lambda/src/functions/still.ts
+++ b/packages/lambda/src/functions/still.ts
@@ -189,6 +189,7 @@ const innerStillHandler = async (
port: null,
server,
logLevel: lambdaParams.logLevel,
+ serializedResolvedPropsWithCustomSchema: JSON.stringify(composition.props),
});
const {key, renderBucketName, customCredentials} = getExpectedOutName(
diff --git a/packages/lambda/src/shared/compress-props.ts b/packages/lambda/src/shared/compress-props.ts
index 87e12ab5d3..8357ab73a8 100644
--- a/packages/lambda/src/shared/compress-props.ts
+++ b/packages/lambda/src/shared/compress-props.ts
@@ -2,11 +2,11 @@ import {getOrCreateBucket} from '../api/get-or-create-bucket';
import type {AwsRegion} from '../client';
import {lambdaReadFile, lambdaWriteFile} from '../functions/helpers/io';
import type {SerializedInputProps} from './constants';
-import {defaultPropsKey, inputPropsKey, resolvedPropsKey} from './constants';
+import {inputPropsKey, resolvedPropsKey} from './constants';
import {randomHash} from './random-hash';
import {streamToString} from './stream-to-string';
-type PropsType = 'input-props' | 'resolved-props' | 'default-props';
+type PropsType = 'input-props' | 'resolved-props';
export const serializeOrThrow = (
inputProps: Record<string, unknown>,
@@ -131,9 +131,5 @@ const makeKey = (type: PropsType, hash: string): string => {
return inputPropsKey(hash);
}
- if (type === 'default-props') {
- return defaultPropsKey(hash);
- }
-
return resolvedPropsKey(hash);
};
diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.ts
index 81fa4969b5..8a8aba220f 100644
--- a/packages/lambda/src/shared/constants.ts
+++ b/packages/lambda/src/shared/constants.ts
@@ -338,7 +338,6 @@ export type LambdaPayloads = {
timeoutInMilliseconds: number;
chromiumOptions: ChromiumOptions;
resolvedProps: SerializedInputProps;
- defaultProps: SerializedInputProps;
scale: number;
everyNthFrame: number;
muted: boolean;
diff --git a/packages/renderer/src/render-frames.ts b/packages/renderer/src/render-frames.ts
index 0154ed769b..078717affc 100644
--- a/packages/renderer/src/render-frames.ts
+++ b/packages/renderer/src/render-frames.ts
@@ -78,7 +78,7 @@ export type InternalRenderFramesOptions = {
scale: number;
port: number | null;
cancelSignal: CancelSignal | undefined;
- composition: VideoConfig;
+ composition: Omit<VideoConfig, 'props' | 'defaultProps'>;
indent: boolean;
server: RemotionServer | undefined;
muted: boolean;
@@ -86,6 +86,7 @@ export type InternalRenderFramesOptions = {
webpackBundleOrServeUrl: string;
logLevel: LogLevel;
serializedInputPropsWithCustomSchema: string;
+ serializedResolvedPropsWithCustomSchema: string;
};
type InnerRenderFramesOptions = {
@@ -109,7 +110,7 @@ type InnerRenderFramesOptions = {
timeoutInMilliseconds: number;
scale: number;
cancelSignal: CancelSignal | undefined;
- composition: VideoConfig;
+ composition: Omit<VideoConfig, 'props' | 'defaultProps'>;
muted: boolean;
onError: (err: Error) => void;
pagesArray: Page[];
@@ -124,6 +125,7 @@ type InnerRenderFramesOptions = {
logLevel: LogLevel;
indent: boolean;
serializedInputPropsWithCustomSchema: string;
+ serializedResolvedPropsWithCustomSchema: string;
};
export type RenderFramesOptions = {
@@ -174,6 +176,7 @@ const innerRenderFrames = async ({
outputDir,
onStart,
serializedInputPropsWithCustomSchema,
+ serializedResolvedPropsWithCustomSchema,
jpegQuality,
imageFormat,
frameRange,
@@ -260,7 +263,7 @@ const innerRenderFrames = async ({
// eslint-disable-next-line max-params
pageFunction: (
id: string,
- props: Record<string, unknown>,
+ props: string,
durationInFrames: number,
fps: number,
height: number,
@@ -269,7 +272,7 @@ const innerRenderFrames = async ({
window.remotion_setBundleMode({
type: 'composition',
compositionName: id,
- props,
+ serializedResolvedPropsWithSchema: props,
compositionDurationInFrames: durationInFrames,
compositionFps: fps,
compositionHeight: height,
@@ -278,7 +281,7 @@ const innerRenderFrames = async ({
},
args: [
composition.id,
- composition.props,
+ serializedResolvedPropsWithCustomSchema,
composition.durationInFrames,
composition.fps,
composition.height,
@@ -581,6 +584,7 @@ export const internalRenderFrames = ({
logLevel,
webpackBundleOrServeUrl,
serializedInputPropsWithCustomSchema,
+ serializedResolvedPropsWithCustomSchema,
}: InternalRenderFramesOptions): Promise<RenderFramesOutput> => {
Internals.validateDimension(
composition.height,
@@ -712,6 +716,7 @@ export const internalRenderFrames = ({
logLevel,
indent,
serializedInputPropsWithCustomSchema,
+ serializedResolvedPropsWithCustomSchema,
});
}
),
@@ -824,6 +829,7 @@ export const renderFrames = (
jpegQuality: jpegQuality ?? DEFAULT_JPEG_QUALITY,
onDownload: onDownload ?? null,
serializedInputPropsWithCustomSchema: JSON.stringify(inputProps ?? {}),
+ serializedResolvedPropsWithCustomSchema: JSON.stringify(composition.props),
puppeteerInstance,
muted: muted ?? false,
onBrowserLog: onBrowserLog ?? null,
diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.ts
index 60c0af1953..5710dfd45e 100644
--- a/packages/renderer/src/render-media.ts
+++ b/packages/renderer/src/render-media.ts
@@ -79,8 +79,9 @@ export type RenderMediaOnProgress = (progress: {
export type InternalRenderMediaOptions = {
outputLocation: string | null;
codec: Codec;
- composition: VideoConfig;
+ composition: Omit<VideoConfig, 'props' | 'defaultProps'>;
serializedInputPropsWithCustomSchema: string;
+ serializedResolvedPropsWithCustomSchema: string;
crf: number | null;
imageFormat: VideoImageFormat;
pixelFormat: PixelFormat;
@@ -216,6 +217,7 @@ export const internalRenderMedia = ({
serveUrl,
server: reusedServer,
logLevel,
+ serializedResolvedPropsWithCustomSchema,
}: InternalRenderMediaOptions): Promise<RenderMediaResult> => {
validateJpegQuality(jpegQuality);
validateQualitySettings({crf, codec, videoBitrate});
@@ -547,6 +549,7 @@ export const internalRenderMedia = ({
logLevel,
indent,
server,
+ serializedResolvedPropsWithCustomSchema,
});
return renderFramesProc;
@@ -756,5 +759,7 @@ export const renderMedia = ({
indent: false,
onCtrlCExit: () => undefined,
server: undefined,
+ // TODO Serialize props
+ serializedResolvedPropsWithCustomSchema: JSON.stringify(composition.props),
});
};
diff --git a/packages/renderer/src/render-still.ts b/packages/renderer/src/render-still.ts
index 8621d3ffbc..05bdf73463 100644
--- a/packages/renderer/src/render-still.ts
+++ b/packages/renderer/src/render-still.ts
@@ -43,6 +43,7 @@ type InternalRenderStillOptions = {
output: string | null;
frame: number;
serializedInputPropsWithCustomSchema: string;
+ serializedResolvedPropsWithCustomSchema: string;
imageFormat: StillImageFormat;
jpegQuality: number;
puppeteerInstance: HeadlessBrowser | null;
@@ -122,6 +123,7 @@ const innerRenderStill = async ({
downloadMap,
logLevel,
indent,
+ serializedResolvedPropsWithCustomSchema,
}: InternalRenderStillOptions & {
downloadMap: DownloadMap;
serveUrl: string;
@@ -266,7 +268,7 @@ const innerRenderStill = async ({
// eslint-disable-next-line max-params
pageFunction: (
id: string,
- props: Record<string, unknown>,
+ props: string,
durationInFrames: number,
fps: number,
height: number,
@@ -275,7 +277,7 @@ const innerRenderStill = async ({
window.remotion_setBundleMode({
type: 'composition',
compositionName: id,
- props,
+ serializedResolvedPropsWithSchema: props,
compositionDurationInFrames: durationInFrames,
compositionFps: fps,
compositionHeight: height,
@@ -284,7 +286,7 @@ const innerRenderStill = async ({
},
args: [
composition.id,
- composition.props,
+ serializedResolvedPropsWithCustomSchema,
composition.durationInFrames,
composition.fps,
composition.height,
@@ -438,5 +440,9 @@ export const renderStill = (
serveUrl,
timeoutInMilliseconds: timeoutInMilliseconds ?? DEFAULT_TIMEOUT,
logLevel: verbose || dumpBrowserLogs ? 'verbose' : getLogLevel(),
+ // TODO Serialize date
+ serializedResolvedPropsWithCustomSchema: JSON.stringify(
+ composition.props ?? {}
+ ),
});
};