Skip to content

🎥 Make videos programmatically with React

color space option

Jonny Burger78a68ca77221
diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.ts
index b030afa3c5..9b22004e45 100644
--- a/packages/cli/src/benchmark.ts
+++ b/packages/cli/src/benchmark.ts
@@ -32,6 +32,7 @@ const {
enforceAudioOption,
mutedOption,
videoCodecOption,
+ colorSpaceOption,
} = BrowserSafeApis.options;
const getValidConcurrency = (cliConcurrency: number | string | null) => {
@@ -190,7 +191,6 @@ export const benchmarkCommand = async (
height,
width,
concurrency: unparsedConcurrency,
- colorSpace,
} = getCliOptions({
isLambda: false,
type: 'series',
@@ -408,7 +408,9 @@ export const benchmarkCommand = async (
offthreadVideoCacheSizeInBytesOption.getValue({
commandLine: parsedCli,
}).value,
- colorSpace,
+ colorSpace: colorSpaceOption.getValue({
+ commandLine: parsedCli,
+ }).value,
repro: false,
finishRenderProgress: () => undefined,
},
diff --git a/packages/cli/src/config/color-space.ts b/packages/cli/src/config/color-space.ts
deleted file mode 100644
index 966bef148f..0000000000
--- a/packages/cli/src/config/color-space.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import type {ColorSpace} from '@remotion/renderer';
-
-let colorSpace: ColorSpace = 'default';
-
-export const getColorSpace = (): ColorSpace => {
- return colorSpace;
-};
-
-export const setColorSpace = (size: ColorSpace) => {
- colorSpace = size;
-};
diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts
index bcf522cf43..9c378b3a8b 100644
--- a/packages/cli/src/config/index.ts
+++ b/packages/cli/src/config/index.ts
@@ -72,7 +72,6 @@ import {
setChromiumIgnoreCertificateErrors,
setChromiumOpenGlRenderer,
} from './chromium-flags';
-import {getColorSpace, setColorSpace} from './color-space';
import type {Concurrency} from './concurrency';
import {setConcurrency} from './concurrency';
import {getEntryPoint, setEntryPoint} from './entry-point';
@@ -125,6 +124,7 @@ const {
enforceAudioOption,
mutedOption,
videoCodecOption,
+ colorSpaceOption,
} = BrowserSafeApis.options;
declare global {
@@ -607,7 +607,7 @@ export const Config: FlatConfig = {
offthreadVideoCacheSizeInBytesOption.setConfig(size);
},
setDeleteAfter,
- setColorSpace,
+ setColorSpace: colorSpaceOption.setConfig,
setBeepOnFinish,
setEnableFolderExpiry,
setRepro,
@@ -659,7 +659,6 @@ export const ConfigInternals = {
getShouldOpenBrowser,
getChromiumUserAgent,
getDeleteAfter,
- getColorSpace,
getEnableFolderExpiry,
getChromiumMultiProcessOnLinux,
getBufferStateDelayInMilliseconds,
diff --git a/packages/cli/src/get-cli-options.ts b/packages/cli/src/get-cli-options.ts
index d085b128f3..c1151ed476 100644
--- a/packages/cli/src/get-cli-options.ts
+++ b/packages/cli/src/get-cli-options.ts
@@ -134,7 +134,6 @@ export const getCliOptions = (options: {
width,
configFileImageFormat: ConfigInternals.getUserPreferredVideoImageFormat(),
deleteAfter: ConfigInternals.getDeleteAfter(),
- colorSpace: ConfigInternals.getColorSpace(),
repro: ConfigInternals.getRepro(),
};
};
diff --git a/packages/cli/src/get-render-defaults.ts b/packages/cli/src/get-render-defaults.ts
index 1b458ef576..ed6ecd892f 100644
--- a/packages/cli/src/get-render-defaults.ts
+++ b/packages/cli/src/get-render-defaults.ts
@@ -13,6 +13,7 @@ const {
videoBitrateOption,
enforceAudioOption,
mutedOption,
+ colorSpaceOption,
} = BrowserSafeApis.options;
export const getRenderDefaults = (): RenderDefaults => {
@@ -49,6 +50,9 @@ export const getRenderDefaults = (): RenderDefaults => {
const muted = mutedOption.getValue({
commandLine: parsedCli,
}).value;
+ const colorSpace = colorSpaceOption.getValue({
+ commandLine: parsedCli,
+ }).value;
const encodingBufferSize = ConfigInternals.getEncodingBufferSize();
const encodingMaxRate = ConfigInternals.getEncodingMaxRate();
@@ -63,7 +67,6 @@ export const getRenderDefaults = (): RenderDefaults => {
const headless = ConfigInternals.getChromiumHeadlessMode();
const ignoreCertificateErrors = ConfigInternals.getIgnoreCertificateErrors();
const openGlRenderer = ConfigInternals.getChromiumOpenGlRenderer();
- const colorSpace = ConfigInternals.getColorSpace();
const userAgent = ConfigInternals.getChromiumUserAgent();
const maxConcurrency = RenderInternals.getMaxConcurrency();
diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsx
index da23da75eb..c16dbcd3f7 100644
--- a/packages/cli/src/render.tsx
+++ b/packages/cli/src/render.tsx
@@ -23,6 +23,7 @@ const {
videoBitrateOption,
enforceAudioOption,
mutedOption,
+ colorSpaceOption,
} = BrowserSafeApis.options;
export const render = async (
@@ -74,7 +75,6 @@ export const render = async (
encodingMaxRate,
encodingBufferSize,
numberOfGifLoops,
- colorSpace,
repro,
} = getCliOptions({
isLambda: false,
@@ -102,6 +102,10 @@ export const render = async (
commandLine: parsedCli,
}).value;
const muted = mutedOption.getValue({commandLine: parsedCli}).value;
+ const colorSpace = colorSpaceOption.getValue({
+ commandLine: parsedCli,
+ }).value;
+
const crf = shouldOutputImageSequence
? null
: crfOption.getValue({commandLine: parsedCli}).value;
diff --git a/packages/cloudrun/src/cli/commands/render/index.ts b/packages/cloudrun/src/cli/commands/render/index.ts
index a897527bf2..5ff5acf9ae 100644
--- a/packages/cloudrun/src/cli/commands/render/index.ts
+++ b/packages/cloudrun/src/cli/commands/render/index.ts
@@ -25,6 +25,7 @@ const {
videoBitrateOption,
enforceAudioOption,
mutedOption,
+ colorSpaceOption,
} = BrowserSafeApis.options;
export const renderCommand = async (
@@ -75,7 +76,6 @@ export const renderCommand = async (
height,
width,
browserExecutable,
- colorSpace,
} = CliInternals.getCliOptions({
type: 'series',
isLambda: true,
@@ -219,6 +219,9 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}
const muted = mutedOption.getValue({
commandLine: CliInternals.parsedCli,
}).value;
+ const colorSpace = colorSpaceOption.getValue({
+ commandLine: CliInternals.parsedCli,
+ }).value;
const res = await internalRenderMediaOnCloudrun({
cloudRunUrl,
serviceName: undefined,
diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.ts
index 5132e505a6..878d521ba7 100644
--- a/packages/lambda/src/cli/commands/render/render.ts
+++ b/packages/lambda/src/cli/commands/render/render.ts
@@ -49,6 +49,7 @@ const {
jpegQualityOption,
videoBitrateOption,
mutedOption,
+ colorSpaceOption,
} = BrowserSafeApis.options;
export const renderCommand = async (
@@ -87,7 +88,6 @@ export const renderCommand = async (
height,
width,
browserExecutable,
- colorSpace,
deleteAfter,
} = CliInternals.getCliOptions({
type: 'series',
@@ -121,6 +121,9 @@ export const renderCommand = async (
const muted = mutedOption.getValue({
commandLine: CliInternals.parsedCli,
}).value;
+ const colorSpace = colorSpaceOption.getValue({
+ commandLine: CliInternals.parsedCli,
+ }).value;
let composition: string = args[1];
if (!composition) {
diff --git a/packages/renderer/src/options/color-space.tsx b/packages/renderer/src/options/color-space.tsx
index e1d5f3626a..1bb21f1f8e 100644
--- a/packages/renderer/src/options/color-space.tsx
+++ b/packages/renderer/src/options/color-space.tsx
@@ -4,6 +4,10 @@ export const validColorSpaces = ['default', 'bt709', 'bt2020-ncl'] as const;
export type ColorSpace = (typeof validColorSpaces)[number];
+let colorSpace: ColorSpace = 'default';
+
+const cliFlag = 'color-space' as const;
+
export const colorSpaceOption = {
name: 'Color space',
cliFlag: 'color-space' as const,
@@ -38,6 +42,29 @@ export const colorSpaceOption = {
docLink: 'https://www.remotion.dev/docs/renderer/render-media#colorspace',
ssrName: 'colorSpace',
type: 'default' as ColorSpace,
+ getValue: ({commandLine}) => {
+ if (commandLine[cliFlag] !== undefined) {
+ return {
+ source: 'cli',
+ value: commandLine[cliFlag] as ColorSpace,
+ };
+ }
+
+ if (colorSpace !== 'default') {
+ return {
+ source: 'config',
+ value: colorSpace,
+ };
+ }
+
+ return {
+ source: 'default',
+ value: 'default',
+ };
+ },
+ setConfig: (value) => {
+ colorSpace = value;
+ },
} satisfies AnyRemotionOption<ColorSpace>;
export const validateColorSpace = (option: unknown) => {