Skip to content

🎥 Make videos programmatically with React

config file image format

Jonny Burger6c8c141f748d
diff --git a/packages/cli/src/config/image-format.ts b/packages/cli/src/config/image-format.ts
index 9d4f40dff5..246707f22e 100644
--- a/packages/cli/src/config/image-format.ts
+++ b/packages/cli/src/config/image-format.ts
@@ -25,6 +25,6 @@ export const setImageFormat = (format: ImageFormat) => {
currentImageFormat = format;
};
-export const getUserPreferredImageFormat = () => {
+export const getUserPreferredImageFormat = (): ImageFormat | undefined => {
return currentImageFormat;
};
diff --git a/packages/cli/src/get-cli-options.ts b/packages/cli/src/get-cli-options.ts
index b53e514e81..454c367f07 100644
--- a/packages/cli/src/get-cli-options.ts
+++ b/packages/cli/src/get-cli-options.ts
@@ -245,5 +245,6 @@ export const getCliOptions = async (options: {
videoBitrate,
height,
width,
+ configFileImageFormat: ConfigInternals.getUserPreferredImageFormat(),
};
};
diff --git a/packages/cli/src/get-render-media-options.ts b/packages/cli/src/get-render-media-options.ts
index bd59bdfb71..8003f134c9 100644
--- a/packages/cli/src/get-render-media-options.ts
+++ b/packages/cli/src/get-render-media-options.ts
@@ -42,13 +42,14 @@ export const getRenderMediaOptions = async ({
videoBitrate,
height,
width,
+ configFileImageFormat,
} = await getCliOptions({
isLambda: false,
type: 'series',
remotionRoot,
});
- const imageFormat = getImageFormat(codec);
+ const imageFormat = getImageFormat(codec, configFileImageFormat);
return {
outputLocation,
diff --git a/packages/cli/src/image-formats.ts b/packages/cli/src/image-formats.ts
index a2a389c065..d2b9631175 100644
--- a/packages/cli/src/image-formats.ts
+++ b/packages/cli/src/image-formats.ts
@@ -1,14 +1,15 @@
import type {ImageFormat} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
-import {ConfigInternals} from './config';
+import type {ConfigInternals} from './config';
export const getImageFormat = (
- codec: ReturnType<typeof ConfigInternals.getOutputCodecOrUndefined>
+ codec: ReturnType<typeof ConfigInternals.getOutputCodecOrUndefined>,
+ configFileImageFormat: ReturnType<
+ typeof ConfigInternals.getUserPreferredImageFormat
+ >
): ImageFormat => {
- const userPreferred = ConfigInternals.getUserPreferredImageFormat();
-
- if (typeof userPreferred !== 'undefined') {
- return userPreferred;
+ if (typeof configFileImageFormat !== 'undefined') {
+ return configFileImageFormat;
}
if (RenderInternals.isAudioCodec(codec)) {
diff --git a/packages/cli/src/preview-server/render-queue/process-still.ts b/packages/cli/src/preview-server/render-queue/process-still.ts
index 5c094c1e8a..53bc63d974 100644
--- a/packages/cli/src/preview-server/render-queue/process-still.ts
+++ b/packages/cli/src/preview-server/render-queue/process-still.ts
@@ -27,6 +27,8 @@ export const processStill = async ({
port,
browser,
puppeteerTimeout,
+ logLevel,
+ configFileImageFormat,
} = await getCliOptions({
isLambda: false,
type: 'still',
@@ -58,6 +60,8 @@ export const processStill = async ({
width: null,
compositionIdFromUi: job.compositionId,
imageFormatFromUi: job.imageFormat,
+ configFileImageFormat,
+ logLevel,
});
// TODO: Write download progress to CLI
// TODO: Allow cancel signal
diff --git a/packages/cli/src/render-flows/still.ts b/packages/cli/src/render-flows/still.ts
index 9cb599b74b..e72006d126 100644
--- a/packages/cli/src/render-flows/still.ts
+++ b/packages/cli/src/render-flows/still.ts
@@ -5,6 +5,8 @@ import type {
BrowserExecutable,
ChromiumOptions,
FfmpegExecutable,
+ ImageFormat,
+ LogLevel,
RenderMediaOnDownload,
StillImageFormat,
} from '@remotion/renderer';
@@ -17,7 +19,6 @@ import {
import {mkdirSync} from 'fs';
import path from 'path';
import {chalk} from '../chalk';
-import {ConfigInternals} from '../config';
import {determineFinalImageFormat} from '../determine-image-format';
import {getAndValidateAbsoluteOutputFile} from '../get-cli-options';
import {getCompositionWithDimensionOverride} from '../get-composition-with-dimension-override';
@@ -59,6 +60,8 @@ export const renderStillFlow = async ({
width,
compositionIdFromUi,
imageFormatFromUi,
+ logLevel,
+ configFileImageFormat,
}: {
remotionRoot: string;
fullEntryPoint: string;
@@ -82,6 +85,8 @@ export const renderStillFlow = async ({
width: number | null;
compositionIdFromUi: string | null;
imageFormatFromUi: StillImageFormat | null;
+ logLevel: LogLevel;
+ configFileImageFormat: ImageFormat | undefined;
}) => {
const startTime = Date.now();
@@ -90,10 +95,7 @@ export const renderStillFlow = async ({
const browserInstance = openBrowser(browser, {
browserExecutable,
chromiumOptions,
- shouldDumpIo: RenderInternals.isEqualOrBelowLogLevel(
- ConfigInternals.Logging.getLogLevel(),
- 'verbose'
- ),
+ shouldDumpIo: RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose'),
forceDeviceScaleFactor: scale,
});
@@ -133,7 +135,7 @@ export const renderStillFlow = async ({
});
const {format: imageFormat, source} = determineFinalImageFormat({
cliFlag: parsedCli['image-format'] ?? null,
- configImageFormat: ConfigInternals.getUserPreferredImageFormat() ?? null,
+ configImageFormat: configFileImageFormat ?? null,
downloadName: null,
outName: getUserPassedOutputLocation(argsAfterComposition),
isLambda: false,
@@ -211,14 +213,14 @@ export const renderStillFlow = async ({
serveUrl: urlOrBundle,
quality,
dumpBrowserLogs: RenderInternals.isEqualOrBelowLogLevel(
- ConfigInternals.Logging.getLogLevel(),
+ logLevel,
'verbose'
),
envVariables,
imageFormat,
inputProps,
chromiumOptions,
- timeoutInMilliseconds: ConfigInternals.getCurrentPuppeteerTimeout(),
+ timeoutInMilliseconds: puppeteerTimeout,
scale,
ffmpegExecutable,
browserExecutable,
diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsx
index fd15861d96..921829079b 100644
--- a/packages/cli/src/render.tsx
+++ b/packages/cli/src/render.tsx
@@ -86,6 +86,7 @@ export const render = async (remotionRoot: string, args: string[]) => {
publicDir,
height,
width,
+ configFileImageFormat,
} = await getCliOptions({
isLambda: false,
type: 'series',
@@ -252,7 +253,8 @@ export const render = async (remotionRoot: string, args: string[]) => {
};
const imageFormat = getImageFormat(
- shouldOutputImageSequence ? undefined : codec
+ shouldOutputImageSequence ? undefined : codec,
+ configFileImageFormat
);
if (shouldOutputImageSequence) {
diff --git a/packages/cli/src/still.ts b/packages/cli/src/still.ts
index 7ee3db1595..a43f885cee 100644
--- a/packages/cli/src/still.ts
+++ b/packages/cli/src/still.ts
@@ -47,6 +47,8 @@ export const still = async (remotionRoot: string, args: string[]) => {
scale,
stillFrame,
width,
+ configFileImageFormat,
+ logLevel,
} = await getCliOptions({
isLambda: false,
type: 'still',
@@ -76,5 +78,7 @@ export const still = async (remotionRoot: string, args: string[]) => {
width,
compositionIdFromUi: null,
imageFormatFromUi: null,
+ configFileImageFormat,
+ logLevel,
});
};
diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.ts
index 604f000499..bbcada6090 100644
--- a/packages/lambda/src/cli/commands/still.ts
+++ b/packages/lambda/src/cli/commands/still.ts
@@ -1,4 +1,4 @@
-import {CliInternals, ConfigInternals} from '@remotion/cli';
+import {CliInternals} from '@remotion/cli';
import {getCompositions, RenderInternals} from '@remotion/renderer';
import {downloadMedia} from '../../api/download-media';
import {renderStillOnLambda} from '../../api/render-still-on-lambda';
@@ -58,6 +58,7 @@ export const stillCommand = async (args: string[], remotionRoot: string) => {
scale,
height,
width,
+ configFileImageFormat,
} = await CliInternals.getCliOptions({
type: 'still',
isLambda: true,
@@ -76,9 +77,10 @@ export const stillCommand = async (args: string[], remotionRoot: string) => {
CliInternals.determineFinalImageFormat({
downloadName,
outName: outName ?? null,
- configImageFormat: ConfigInternals.getUserPreferredImageFormat() ?? null,
+ configImageFormat: configFileImageFormat ?? null,
cliFlag: CliInternals.parsedCli['image-format'] ?? null,
isLambda: true,
+ fromUi: null,
});
try {