Skip to content

🎥 Make videos programmatically with React

take image format from CLI

Jonny Burger3b7fd55304ed
diff --git a/packages/cli/src/get-render-media-options.ts b/packages/cli/src/get-render-media-options.ts
index 8003f134c9..8e513f5932 100644
--- a/packages/cli/src/get-render-media-options.ts
+++ b/packages/cli/src/get-render-media-options.ts
@@ -49,7 +49,11 @@ export const getRenderMediaOptions = async ({
remotionRoot,
});
- const imageFormat = getImageFormat(codec, configFileImageFormat);
+ const imageFormat = getImageFormat({
+ codec,
+ configFileImageFormat,
+ uiImageFormat: null,
+ });
return {
outputLocation,
diff --git a/packages/cli/src/image-formats.ts b/packages/cli/src/image-formats.ts
index d2b9631175..b4efa4f264 100644
--- a/packages/cli/src/image-formats.ts
+++ b/packages/cli/src/image-formats.ts
@@ -2,12 +2,21 @@ import type {ImageFormat} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import type {ConfigInternals} from './config';
-export const getImageFormat = (
- codec: ReturnType<typeof ConfigInternals.getOutputCodecOrUndefined>,
+export const getImageFormat = ({
+ codec,
+ configFileImageFormat,
+ uiImageFormat,
+}: {
+ codec: ReturnType<typeof ConfigInternals.getOutputCodecOrUndefined>;
configFileImageFormat: ReturnType<
typeof ConfigInternals.getUserPreferredImageFormat
- >
-): ImageFormat => {
+ >;
+ uiImageFormat: ImageFormat | null;
+}): ImageFormat => {
+ if (uiImageFormat !== null) {
+ return uiImageFormat;
+ }
+
if (typeof configFileImageFormat !== 'undefined') {
return configFileImageFormat;
}
diff --git a/packages/cli/src/preview-server/render-queue/process-video.ts b/packages/cli/src/preview-server/render-queue/process-video.ts
index 84356d7405..7215a049b0 100644
--- a/packages/cli/src/preview-server/render-queue/process-video.ts
+++ b/packages/cli/src/preview-server/render-queue/process-video.ts
@@ -75,6 +75,7 @@ export const processVideoJob = async ({
addCleanupCallback,
outputLocationFromUI: job.outName,
uiCodec: job.codec,
+ uiImageFormat: job.imageFormat,
});
// TODO: Allow cancel signal
// TODO: Accept CLI options
diff --git a/packages/cli/src/render-flows/render.ts b/packages/cli/src/render-flows/render.ts
index fac0642326..c4028ff1f8 100644
--- a/packages/cli/src/render-flows/render.ts
+++ b/packages/cli/src/render-flows/render.ts
@@ -76,6 +76,7 @@ export const renderCompFlow = async ({
onProgress,
addCleanupCallback,
uiCodec,
+ uiImageFormat,
}: {
remotionRoot: string;
fullEntryPoint: string;
@@ -109,6 +110,7 @@ export const renderCompFlow = async ({
onProgress: JobProgressCallback;
addCleanupCallback: (cb: () => Promise<void>) => void;
uiCodec: Codec | null;
+ uiImageFormat: ImageFormat | null;
}) => {
const downloads: DownloadProgress[] = [];
const downloadMap = RenderInternals.makeDownloadMap();
@@ -303,11 +305,11 @@ export const renderCompFlow = async ({
return renderProgress.update(output);
};
- // TODO: Should take the one from the UI instead
- const imageFormat = getImageFormat(
- shouldOutputImageSequence ? undefined : codec,
- configFileImageFormat
- );
+ const imageFormat = getImageFormat({
+ codec: shouldOutputImageSequence ? undefined : codec,
+ configFileImageFormat,
+ uiImageFormat,
+ });
if (shouldOutputImageSequence) {
fs.mkdirSync(absoluteOutputFile, {
diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsx
index e785bf7f54..344fb8ad1e 100644
--- a/packages/cli/src/render.tsx
+++ b/packages/cli/src/render.tsx
@@ -96,6 +96,7 @@ export const render = async (remotionRoot: string, args: string[]) => {
},
outputLocationFromUI: null,
uiCodec: null,
+ uiImageFormat: null,
});
} finally {
await Promise.all(jobCleanups.map((c) => c()));
diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.ts
index ac25e1d3d1..be28190422 100644
--- a/packages/lambda/src/cli/commands/render/render.ts
+++ b/packages/lambda/src/cli/commands/render/render.ts
@@ -88,7 +88,11 @@ export const renderCommand = async (args: string[], remotionRoot: string) => {
remotionRoot,
});
- const imageFormat = CliInternals.getImageFormat(codec, configFileImageFormat);
+ const imageFormat = CliInternals.getImageFormat({
+ codec,
+ configFileImageFormat,
+ uiImageFormat: null,
+ });
const functionName = await findFunctionName();