Skip to content

🎥 Make videos programmatically with React

`remotion`: Allow adding a `defaultOutName` in a composition

Jonny Burger9cbf9dbfb16c
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 4c38222aed..720cb1b250 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -35,5 +35,8 @@
"rust-analyzer.linkedProjects": ["packages/compositor/Cargo.toml"],
"search.exclude": {
"packages/**/dist": true
+ },
+ "files.associations": {
+ "*.mdx": "markdown"
}
}
diff --git a/packages/bundler/renderEntry.tsx b/packages/bundler/renderEntry.tsx
index cf344b34a6..050987a759 100644
--- a/packages/bundler/renderEntry.tsx
+++ b/packages/bundler/renderEntry.tsx
@@ -141,6 +141,7 @@ const GetVideo: React.FC<{state: BundleState}> = ({state}) => {
height: state.compositionHeight,
width: state.compositionWidth,
defaultCodec: state.compositionDefaultCodec,
+ defaultOutName: state.compositionDefaultOutName,
});
}
}, [compositions, compositions.compositions, state, video]);
diff --git a/packages/cli/src/get-filename.ts b/packages/cli/src/get-filename.ts
index 23e2b1f217..afdbb16e3c 100644
--- a/packages/cli/src/get-filename.ts
+++ b/packages/cli/src/get-filename.ts
@@ -6,6 +6,7 @@ import {getOutputLocation} from './user-passed-output-location';
export const getOutputFilename = ({
imageSequence,
compositionName,
+ compositionDefaultOutName,
defaultExtension,
args,
fromUi,
@@ -14,6 +15,7 @@ export const getOutputFilename = ({
}: {
imageSequence: boolean;
compositionName: string;
+ compositionDefaultOutName: string | null;
defaultExtension: string;
args: (string | number)[];
fromUi: string | null;
@@ -30,6 +32,7 @@ export const getOutputFilename = ({
args,
type: imageSequence ? 'sequence' : 'asset',
outputLocationFromUi: null,
+ compositionDefaultOutName,
});
const extension = RenderInternals.getExtensionOfFilename(String(filename));
diff --git a/packages/cli/src/render-flows/render.ts b/packages/cli/src/render-flows/render.ts
index 8e2d1cc077..bc50fa9b26 100644
--- a/packages/cli/src/render-flows/render.ts
+++ b/packages/cli/src/render-flows/render.ts
@@ -386,6 +386,7 @@ export const renderVideoFlow = async ({
const relativeOutputLocation = getOutputFilename({
imageSequence: shouldOutputImageSequence,
compositionName: compositionId,
+ compositionDefaultOutName: config.defaultOutName,
defaultExtension: RenderInternals.getFileExtensionFromCodec(
codec,
audioCodec,
diff --git a/packages/cli/src/render-flows/still.ts b/packages/cli/src/render-flows/still.ts
index 44ae633d07..5a8fabc9f5 100644
--- a/packages/cli/src/render-flows/still.ts
+++ b/packages/cli/src/render-flows/still.ts
@@ -268,6 +268,7 @@ export const renderStillFlow = async ({
args: argsAfterComposition,
type: 'asset',
outputLocationFromUi,
+ compositionDefaultOutName: config.defaultOutName,
});
const absoluteOutputLocation = getAndValidateAbsoluteOutputFile(
diff --git a/packages/cli/src/user-passed-output-location.ts b/packages/cli/src/user-passed-output-location.ts
index bba3999d75..c885039d49 100644
--- a/packages/cli/src/user-passed-output-location.ts
+++ b/packages/cli/src/user-passed-output-location.ts
@@ -21,9 +21,11 @@ export const getOutputLocation = ({
args,
type,
outputLocationFromUi,
+ compositionDefaultOutName,
}: {
compositionId: string;
outputLocationFromUi: string | null;
+ compositionDefaultOutName: string | null;
defaultExtension: string;
args: (string | number)[];
type: 'asset' | 'sequence';
@@ -43,6 +45,7 @@ export const getOutputLocation = ({
compositionName: compositionId,
defaultExtension,
type,
+ compositionDefaultOutName,
})
);
};
diff --git a/packages/core/src/Composition.tsx b/packages/core/src/Composition.tsx
index 65c48337d9..c7e8b8bd71 100644
--- a/packages/core/src/Composition.tsx
+++ b/packages/core/src/Composition.tsx
@@ -40,6 +40,7 @@ export type CalcMetadataReturnType<T extends Record<string, unknown>> = {
height?: number;
props?: T;
defaultCodec?: Codec;
+ defaultOutName?: string;
};
export type CalculateMetadataFunction<T extends Record<string, unknown>> =
diff --git a/packages/core/src/CompositionManagerContext.tsx b/packages/core/src/CompositionManagerContext.tsx
index 57a0b868f7..6b30f302db 100644
--- a/packages/core/src/CompositionManagerContext.tsx
+++ b/packages/core/src/CompositionManagerContext.tsx
@@ -7,7 +7,13 @@ import type {VideoConfig} from './video-config.js';
export type BaseMetadata = Pick<
VideoConfig,
- 'durationInFrames' | 'fps' | 'props' | 'height' | 'width' | 'defaultCodec'
+ | 'durationInFrames'
+ | 'fps'
+ | 'props'
+ | 'height'
+ | 'width'
+ | 'defaultCodec'
+ | 'defaultOutName'
>;
export type CanvasContent =
diff --git a/packages/core/src/ResolveCompositionConfig.tsx b/packages/core/src/ResolveCompositionConfig.tsx
index 763bbf5b20..c8491f6d08 100644
--- a/packages/core/src/ResolveCompositionConfig.tsx
+++ b/packages/core/src/ResolveCompositionConfig.tsx
@@ -454,6 +454,7 @@ export const useResolvedVideoConfig = (
props: currentCompositionMetadata.props,
defaultProps: composition.defaultProps ?? {},
defaultCodec: currentCompositionMetadata.defaultCodec,
+ defaultOutName: currentCompositionMetadata.defaultOutName,
},
};
}
@@ -496,6 +497,7 @@ export const useResolvedVideoConfig = (
: (getInputProps() ?? {})),
},
defaultCodec: null,
+ defaultOutName: null,
},
};
}
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index c9c6e4b87c..652a9d1055 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -89,6 +89,7 @@ export type BundleState =
compositionWidth: number;
compositionFps: number;
compositionDefaultCodec: Codec;
+ compositionDefaultOutName: string | null;
};
checkMultipleRemotionVersions();
diff --git a/packages/core/src/resolve-video-config.ts b/packages/core/src/resolve-video-config.ts
index e31b26d1f0..7e452e21a5 100644
--- a/packages/core/src/resolve-video-config.ts
+++ b/packages/core/src/resolve-video-config.ts
@@ -64,7 +64,9 @@ const validateCalculated = ({
const defaultCodec = calculated?.defaultCodec;
validateDefaultCodec(defaultCodec, calculateMetadataErrorLocation);
- return {width, height, fps, durationInFrames, defaultCodec};
+ const defaultOutName = calculated?.defaultOutName;
+
+ return {width, height, fps, durationInFrames, defaultCodec, defaultOutName};
};
type ResolveVideoConfigParams = {
@@ -107,15 +109,21 @@ export const resolveVideoConfig = ({
'then' in calculatedProm
) {
return calculatedProm.then((c) => {
- const {height, width, durationInFrames, fps, defaultCodec} =
- validateCalculated({
- calculated: c,
- compositionDurationInFrames,
- compositionFps,
- compositionHeight,
- compositionWidth,
- compositionId,
- });
+ const {
+ height,
+ width,
+ durationInFrames,
+ fps,
+ defaultCodec,
+ defaultOutName,
+ } = validateCalculated({
+ calculated: c,
+ compositionDurationInFrames,
+ compositionFps,
+ compositionHeight,
+ compositionWidth,
+ compositionId,
+ });
return {
width,
height,
@@ -125,6 +133,7 @@ export const resolveVideoConfig = ({
defaultProps: serializeThenDeserializeInStudio(defaultProps),
props: serializeThenDeserializeInStudio(c.props ?? originalProps),
defaultCodec: defaultCodec ?? null,
+ defaultOutName: defaultOutName ?? null,
};
});
}
@@ -145,6 +154,7 @@ export const resolveVideoConfig = ({
defaultProps: serializeThenDeserializeInStudio(defaultProps ?? {}),
props: serializeThenDeserializeInStudio(originalProps),
defaultCodec: null,
+ defaultOutName: null,
};
}
@@ -156,6 +166,7 @@ export const resolveVideoConfig = ({
calculatedProm.props ?? originalProps,
),
defaultCodec: calculatedProm.defaultCodec ?? null,
+ defaultOutName: calculatedProm.defaultOutName ?? null,
};
};
diff --git a/packages/core/src/test/use-media-in-timeline.test.tsx b/packages/core/src/test/use-media-in-timeline.test.tsx
index 9a6d90319d..b2865bff56 100644
--- a/packages/core/src/test/use-media-in-timeline.test.tsx
+++ b/packages/core/src/test/use-media-in-timeline.test.tsx
@@ -31,6 +31,7 @@ beforeAll(() => {
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
}));
});
afterAll(() => {
diff --git a/packages/core/src/use-unsafe-video-config.ts b/packages/core/src/use-unsafe-video-config.ts
index 9076120f99..82cc79e60c 100644
--- a/packages/core/src/use-unsafe-video-config.ts
+++ b/packages/core/src/use-unsafe-video-config.ts
@@ -24,6 +24,7 @@ export const useUnsafeVideoConfig = (): VideoConfig | null => {
defaultProps,
props,
defaultCodec,
+ defaultOutName,
} = video;
return {
@@ -35,6 +36,7 @@ export const useUnsafeVideoConfig = (): VideoConfig | null => {
defaultProps,
props,
defaultCodec,
+ defaultOutName,
};
}, [ctxDuration, ctxHeight, ctxWidth, video]);
};
diff --git a/packages/core/src/video-config.ts b/packages/core/src/video-config.ts
index 598c687941..cd881e84a1 100644
--- a/packages/core/src/video-config.ts
+++ b/packages/core/src/video-config.ts
@@ -9,4 +9,5 @@ export type VideoConfig = {
defaultProps: Record<string, unknown>;
props: Record<string, unknown>;
defaultCodec: Codec | null;
+ defaultOutName: string | null;
};
diff --git a/packages/docs/docs/4-0-migration.mdx b/packages/docs/docs/4-0-migration.mdx
index 256c88b313..fba926546d 100644
--- a/packages/docs/docs/4-0-migration.mdx
+++ b/packages/docs/docs/4-0-migration.mdx
@@ -326,6 +326,7 @@ const composition = {
id: 'comp-name',
defaultProps: {},
defaultCodec: null,
+ defaultOutName: null,
} as const;
// ---cut---
diff --git a/packages/docs/docs/artifacts.mdx b/packages/docs/docs/artifacts.mdx
index 42a309befb..da73d962fd 100644
--- a/packages/docs/docs/artifacts.mdx
+++ b/packages/docs/docs/artifacts.mdx
@@ -70,6 +70,7 @@ const composition: VideoConfig = {
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
id: 'hi',
durationInFrames: 100,
};
diff --git a/packages/docs/docs/calculate-metadata.mdx b/packages/docs/docs/calculate-metadata.mdx
index 014e60bbf6..51b7564c51 100644
--- a/packages/docs/docs/calculate-metadata.mdx
+++ b/packages/docs/docs/calculate-metadata.mdx
@@ -2,7 +2,7 @@
image: /generated/articles-docs-calculate-metadata.png
id: calculate-metadata
title: calculateMetadata()
-crumb: "API"
+crumb: 'API'
---
# calculateMetadata()<AvailableFrom v="4.0.0" />
@@ -12,10 +12,12 @@ crumb: "API"
Use it if you:
<Step>1</Step> need to make the `durationInFrames`, `width`, `height`, or `fps` <a href="/docs/dynamic-metadata">dynamic based on some data</a>
-<br/><Step>2</Step> want to transform the props passed to the composition, for example
-to do <a href="/docs/data-fetching">data fetching</a>
-<br/><Step>3</Step> want to add a per-composition default codec
-<br/><Step>4</Step> want to run code once, before the actual render starts.
+<br />
+<Step>2</Step> want to transform the props passed to the composition, for example to do <a href="/docs/data-fetching">data fetching</a>
+<br />
+<Step>3</Step> want to add a per-composition default codec
+<br />
+<Step>4</Step> want to run code once, before the actual render starts.
The `calculateMetadata()` function is called a single time, independently from the concurrency of the render.
It runs in a separate tab, as part of the render process calling [`selectComposition()`](/docs/renderer/select-composition).
@@ -26,34 +28,30 @@ Define a function, you may type it using `CalculateMetadataFunction` - the gener
```tsx twoslash title="src/Root.tsx"
// @filename: MyComp.tsx
-import React from "react";
+import React from 'react';
export type MyComponentProps = {
text: string;
duration: number;
};
-export const MyComponent: React.FC<MyComponentProps> = ({ text }) => {
+export const MyComponent: React.FC<MyComponentProps> = ({text}) => {
return <div>{text}</div>;
};
// @filename: Vid.tsx
// ---cut---
-import React from "react";
-import { CalculateMetadataFunction, Composition } from "remotion";
-import { MyComponent, MyComponentProps } from "./MyComp";
-
-const calculateMetadata: CalculateMetadataFunction<MyComponentProps> = ({
- props,
- defaultProps,
- abortSignal,
-}) => {
+import React from 'react';
+import {CalculateMetadataFunction, Composition} from 'remotion';
+import {MyComponent, MyComponentProps} from './MyComp';
+
+const calculateMetadata: CalculateMetadataFunction<MyComponentProps> = ({props, defaultProps, abortSignal}) => {
return {
// Change the metadata
durationInFrames: props.duration,
// or transform some props
props,
// or add per-composition default codec
- defaultCodec: "h264",
+ defaultCodec: 'h264',
};
};
@@ -67,7 +65,7 @@ export const Root: React.FC = () => {
width={1920}
height={1080}
defaultProps={{
- text: "Hello World",
+ text: 'Hello World',
duration: 1,
}}
calculateMetadata={calculateMetadata}
@@ -91,6 +89,7 @@ The function must return an pure JSON-serializable object, which can contain the
- `height` _optional_: The height of the composition in pixels
- `fps` _optional_: The frames per second of the composition
- `defaultCodec` _optional_: The default codec to use for the composition.
+- `defaultOutName` _optional_: The default output name when rendering (without file extension) <AvailableFrom v="4.0.268" />
If you return a field, it will take precendence over the props directly passed to the composition. The defaultCodec returned will have a higher priority than the config file, but less priority than explicitly passing the option to renderMedia() i.e. the composition will be rendered with this codec if nothing with higher priority was specified.
diff --git a/packages/docs/docs/renderer/make-cancel-signal.mdx b/packages/docs/docs/renderer/make-cancel-signal.mdx
index 494a0366c2..dfbc3b80fd 100644
--- a/packages/docs/docs/renderer/make-cancel-signal.mdx
+++ b/packages/docs/docs/renderer/make-cancel-signal.mdx
@@ -23,6 +23,7 @@ const composition: VideoConfig = {
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
};
// ---cut---
import {makeCancelSignal, renderMedia} from '@remotion/renderer';
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index 34397e9a62..cb03eac49e 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -804,6 +804,7 @@ export const Index: React.FC = () => {
calculateMetadata={() => {
return {
defaultCodec: 'aac',
+ defaultOutName: `out-${Date.now()}`,
};
}}
durationInFrames={100}
@@ -814,9 +815,6 @@ export const Index: React.FC = () => {
width={1000}
height={1000}
defaultProps={{flag: false}}
- calculateMetadata={async () => {
- return {};
- }}
/>
<Still id="font-demo" component={FontDemo} width={1000} height={1000} />
<Composition
diff --git a/packages/it-tests/src/ssr/cancel-after-success.test.ts b/packages/it-tests/src/ssr/cancel-after-success.test.ts
index e2d2becece..854a89bfa9 100644
--- a/packages/it-tests/src/ssr/cancel-after-success.test.ts
+++ b/packages/it-tests/src/ssr/cancel-after-success.test.ts
@@ -19,6 +19,7 @@ test('Cancelling after success should not throw error', async () => {
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
concurrency: 1,
outputLocation,
diff --git a/packages/it-tests/src/ssr/cancel-renderframes.test.ts b/packages/it-tests/src/ssr/cancel-renderframes.test.ts
index 131d03aa60..fcf262cb5e 100644
--- a/packages/it-tests/src/ssr/cancel-renderframes.test.ts
+++ b/packages/it-tests/src/ssr/cancel-renderframes.test.ts
@@ -24,6 +24,7 @@ test('Should be able to cancel render', async () => {
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
cancelSignal,
imageFormat: 'jpeg',
diff --git a/packages/it-tests/src/ssr/cancel-rendermedia.test.ts b/packages/it-tests/src/ssr/cancel-rendermedia.test.ts
index 35b1aed392..d5a0319116 100644
--- a/packages/it-tests/src/ssr/cancel-rendermedia.test.ts
+++ b/packages/it-tests/src/ssr/cancel-rendermedia.test.ts
@@ -17,6 +17,7 @@ test('Should be able to cancel render', async () => {
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
outputLocation: 'out/render.mp4',
cancelSignal,
diff --git a/packages/it-tests/src/ssr/cancel-renderstill.test.ts b/packages/it-tests/src/ssr/cancel-renderstill.test.ts
index 91d960bf58..ad88da8751 100644
--- a/packages/it-tests/src/ssr/cancel-renderstill.test.ts
+++ b/packages/it-tests/src/ssr/cancel-renderstill.test.ts
@@ -16,6 +16,7 @@ test('Should be able to cancel render', async () => {
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
cancelSignal,
output: 'out/hithere.png',
diff --git a/packages/it-tests/src/ssr/fatal-error-correct-error.test.ts b/packages/it-tests/src/ssr/fatal-error-correct-error.test.ts
index 2a2e344d79..904fc66434 100644
--- a/packages/it-tests/src/ssr/fatal-error-correct-error.test.ts
+++ b/packages/it-tests/src/ssr/fatal-error-correct-error.test.ts
@@ -16,6 +16,7 @@ test('Fatal error on frame 10 should yield correct error', async () => {
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
logLevel: 'error',
outputLocation: 'out/render.mp4',
diff --git a/packages/it-tests/src/ssr/render-media.test.ts b/packages/it-tests/src/ssr/render-media.test.ts
index 8edb64973c..d5782ec107 100644
--- a/packages/it-tests/src/ssr/render-media.test.ts
+++ b/packages/it-tests/src/ssr/render-media.test.ts
@@ -88,6 +88,7 @@ test('should fail on invalid CRF', async () => {
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
frameRange: [0, 2],
puppeteerInstance: browserInstance,
@@ -139,6 +140,7 @@ test('Should fail invalid serve URL', async () => {
width: 1080,
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
});
} catch (err) {
diff --git a/packages/renderer/src/get-compositions.ts b/packages/renderer/src/get-compositions.ts
index 046bb0e7ff..daaaf3a925 100644
--- a/packages/renderer/src/get-compositions.ts
+++ b/packages/renderer/src/get-compositions.ts
@@ -127,7 +127,15 @@ const innerGetCompositions = async ({
>;
return res.map((r) => {
- const {width, durationInFrames, fps, height, id, defaultCodec} = r;
+ const {
+ width,
+ durationInFrames,
+ fps,
+ height,
+ id,
+ defaultCodec,
+ defaultOutName,
+ } = r;
return {
id,
@@ -142,6 +150,7 @@ const innerGetCompositions = async ({
r.serializedDefaultPropsWithCustomSchema,
),
defaultCodec,
+ defaultOutName,
};
});
};
diff --git a/packages/renderer/src/make-page.ts b/packages/renderer/src/make-page.ts
index 9b68bbbe05..2fc41575fb 100644
--- a/packages/renderer/src/make-page.ts
+++ b/packages/renderer/src/make-page.ts
@@ -97,6 +97,7 @@ export const makePage = async ({
height: number,
width: number,
defaultCodec: Codec,
+ defaultOutName: string | null,
) => {
window.remotion_setBundleMode({
type: 'composition',
@@ -107,6 +108,7 @@ export const makePage = async ({
compositionHeight: height,
compositionWidth: width,
compositionDefaultCodec: defaultCodec,
+ compositionDefaultOutName: defaultOutName,
});
},
args: [
@@ -117,6 +119,7 @@ export const makePage = async ({
composition.height,
composition.width,
composition.defaultCodec,
+ composition.defaultOutName,
],
frame: null,
page,
diff --git a/packages/renderer/src/render-still.ts b/packages/renderer/src/render-still.ts
index d2f2599af0..e6175300d7 100644
--- a/packages/renderer/src/render-still.ts
+++ b/packages/renderer/src/render-still.ts
@@ -287,6 +287,7 @@ const innerRenderStill = async ({
height: number,
width: number,
defaultCodec: Codec,
+ defaultOutName: string | null,
) => {
window.remotion_setBundleMode({
type: 'composition',
@@ -297,6 +298,7 @@ const innerRenderStill = async ({
compositionHeight: height,
compositionWidth: width,
compositionDefaultCodec: defaultCodec,
+ compositionDefaultOutName: defaultOutName,
});
},
args: [
@@ -307,6 +309,7 @@ const innerRenderStill = async ({
composition.height,
composition.width,
composition.defaultCodec,
+ composition.defaultOutName,
],
frame: null,
page,
diff --git a/packages/renderer/src/select-composition.ts b/packages/renderer/src/select-composition.ts
index b49f8d4cf9..5966c6a8f7 100644
--- a/packages/renderer/src/select-composition.ts
+++ b/packages/renderer/src/select-composition.ts
@@ -154,7 +154,8 @@ const innerSelectComposition = async ({
ReturnType<typeof window.remotion_calculateComposition>
>;
- const {width, durationInFrames, fps, height, defaultCodec} = res;
+ const {width, durationInFrames, fps, height, defaultCodec, defaultOutName} =
+ res;
return {
metadata: {
id,
@@ -169,6 +170,7 @@ const innerSelectComposition = async ({
res.serializedDefaultPropsWithCustomSchema,
),
defaultCodec,
+ defaultOutName,
},
propsSize: size,
};
diff --git a/packages/renderer/src/test/render-still.test.ts b/packages/renderer/src/test/render-still.test.ts
index 2bddcff647..8f28672e73 100644
--- a/packages/renderer/src/test/render-still.test.ts
+++ b/packages/renderer/src/test/render-still.test.ts
@@ -20,6 +20,7 @@ test(
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
frame: 0,
output: '/file/output.png',
@@ -47,6 +48,7 @@ test(
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
frame: 0,
serveUrl:
@@ -74,6 +76,7 @@ test(
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
frame: 200,
output: '/file/output.png',
@@ -102,6 +105,7 @@ test(
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
// @ts-expect-error
imageFormat: 'jjj',
diff --git a/packages/renderer/src/test/validate-config.test.ts b/packages/renderer/src/test/validate-config.test.ts
index b533caf391..fd75a8e9a1 100644
--- a/packages/renderer/src/test/validate-config.test.ts
+++ b/packages/renderer/src/test/validate-config.test.ts
@@ -15,6 +15,7 @@ describe('Should validate invalid data passed to renderFrames', () => {
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
}),
).toThrow(
@@ -34,6 +35,7 @@ describe('Should validate invalid data passed to renderFrames', () => {
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
}),
).toThrow(
@@ -53,6 +55,7 @@ describe('Should validate invalid data passed to renderFrames', () => {
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
}),
).toThrow(
@@ -72,6 +75,7 @@ describe('Should validate invalid data passed to renderFrames', () => {
defaultProps: {},
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
}),
).toThrow(
diff --git a/packages/serverless/src/handlers/renderer.ts b/packages/serverless/src/handlers/renderer.ts
index b9a2f1ffdf..1fe0d26db6 100644
--- a/packages/serverless/src/handlers/renderer.ts
+++ b/packages/serverless/src/handlers/renderer.ts
@@ -233,6 +233,7 @@ const renderHandler = async <Provider extends CloudProvider>({
height: params.height,
width: params.width,
defaultCodec: null,
+ defaultOutName: null,
},
imageFormat: params.imageFormat,
serializedInputPropsWithCustomSchema,
diff --git a/packages/studio-shared/src/get-default-out-name.ts b/packages/studio-shared/src/get-default-out-name.ts
index 186f6d17d8..cb4a815d03 100644
--- a/packages/studio-shared/src/get-default-out-name.ts
+++ b/packages/studio-shared/src/get-default-out-name.ts
@@ -2,14 +2,18 @@ export const getDefaultOutLocation = ({
compositionName,
defaultExtension,
type,
+ compositionDefaultOutName,
}: {
compositionName: string;
+ compositionDefaultOutName: string | null;
defaultExtension: string;
type: 'asset' | 'sequence';
}) => {
+ const nameToUse = compositionDefaultOutName ?? compositionName;
+
if (type === 'sequence') {
- return `out/${compositionName}`;
+ return `out/${nameToUse}`;
}
- return `out/${compositionName}.${defaultExtension}`;
+ return `out/${nameToUse}.${defaultExtension}`;
};
diff --git a/packages/studio/src/components/RenderModal/RenderModal.tsx b/packages/studio/src/components/RenderModal/RenderModal.tsx
index 90e51fba12..0c23314d88 100644
--- a/packages/studio/src/components/RenderModal/RenderModal.tsx
+++ b/packages/studio/src/components/RenderModal/RenderModal.tsx
@@ -371,6 +371,7 @@ const RenderModal: React.FC<
)
: initialStillImageFormat,
type: 'asset',
+ compositionDefaultOutName: resolvedComposition.defaultOutName,
});
});
diff --git a/packages/test-utils/src/composition-manager-context.ts b/packages/test-utils/src/composition-manager-context.ts
index 52931a65b2..22b54e0587 100644
--- a/packages/test-utils/src/composition-manager-context.ts
+++ b/packages/test-utils/src/composition-manager-context.ts
@@ -14,6 +14,7 @@ export const makeMockCompositionManagerContext =
width: 100,
props: {},
defaultCodec: null,
+ defaultOutName: null,
},
folders: [],
registerComposition: () => undefined,