Skip to content

🎥 Make videos programmatically with React

fix --image-format while rendering

Jonny Burgeref6499083c19
diff --git a/packages/cli/src/image-formats.ts b/packages/cli/src/image-formats.ts
index 4a8b25c90a..f878a1d2dc 100644
--- a/packages/cli/src/image-formats.ts
+++ b/packages/cli/src/image-formats.ts
@@ -1,14 +1,27 @@
import type {VideoImageFormat} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import {ConfigInternals} from './config';
+import {parsedCli} from './parse-command-line';
export const getVideoImageFormat = (
codec: ReturnType<typeof ConfigInternals.getOutputCodecOrUndefined>
): VideoImageFormat => {
- const userPreferred = ConfigInternals.getUserPreferredVideoImageFormat();
+ const configFileOption = ConfigInternals.getUserPreferredVideoImageFormat();
- if (typeof userPreferred !== 'undefined') {
- return userPreferred;
+ if (typeof configFileOption !== 'undefined') {
+ return configFileOption;
+ }
+
+ if (typeof parsedCli['image-format'] !== 'undefined') {
+ if (
+ !(RenderInternals.validVideoImageFormats as readonly string[]).includes(
+ parsedCli['image-format'] as string
+ )
+ ) {
+ throw new Error(`Invalid image format: ${parsedCli['image-format']}`);
+ }
+
+ return parsedCli['image-format'] as VideoImageFormat;
}
if (RenderInternals.isAudioCodec(codec)) {