Skip to content

🎥 Make videos programmatically with React

Remotion 5.0: Make bt709 the default color spac

Jonny Burger44c19b913540
diff --git a/packages/cli/src/render-flows/render.ts b/packages/cli/src/render-flows/render.ts
index b1fe7430d4..7c12654c41 100644
--- a/packages/cli/src/render-flows/render.ts
+++ b/packages/cli/src/render-flows/render.ts
@@ -152,7 +152,7 @@ export const renderVideoFlow = async ({
audioCodec: AudioCodec | null;
disallowParallelEncoding: boolean;
offthreadVideoCacheSizeInBytes: number | null;
- colorSpace: ColorSpace;
+ colorSpace: ColorSpace | null;
repro: boolean;
binariesDirectory: string | null;
forSeamlessAacConcatenation: boolean;
diff --git a/packages/cli/src/render-queue/process-video.ts b/packages/cli/src/render-queue/process-video.ts
index d9dd097b7f..a71e7331ee 100644
--- a/packages/cli/src/render-queue/process-video.ts
+++ b/packages/cli/src/render-queue/process-video.ts
@@ -87,7 +87,7 @@ export const processVideoJob = async ({
disallowParallelEncoding:
job.type === 'video' ? job.disallowParallelEncoding : false,
offthreadVideoCacheSizeInBytes: job.offthreadVideoCacheSizeInBytes,
- colorSpace: job.type === 'video' ? job.colorSpace : 'default',
+ colorSpace: job.type === 'video' ? job.colorSpace : null,
repro: job.repro,
binariesDirectory: job.binariesDirectory,
forSeamlessAacConcatenation:
diff --git a/packages/cloudrun/src/api/render-media-on-cloudrun.ts b/packages/cloudrun/src/api/render-media-on-cloudrun.ts
index e0b6e0308d..2b0ac40c89 100644
--- a/packages/cloudrun/src/api/render-media-on-cloudrun.ts
+++ b/packages/cloudrun/src/api/render-media-on-cloudrun.ts
@@ -181,7 +181,7 @@ const internalRenderMediaOnCloudrunRaw = async ({
enforceAudioTrack: enforceAudioTrack ?? false,
preferLossless: preferLossless ?? false,
offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,
- colorSpace: colorSpace ?? 'default',
+ colorSpace: colorSpace ?? null,
clientVersion: VERSION,
};
diff --git a/packages/cloudrun/src/functions/helpers/payloads.ts b/packages/cloudrun/src/functions/helpers/payloads.ts
index 8840ebf8a9..faa131afc1 100644
--- a/packages/cloudrun/src/functions/helpers/payloads.ts
+++ b/packages/cloudrun/src/functions/helpers/payloads.ts
@@ -53,7 +53,7 @@ export const CloudRunPayload = z.discriminatedUnion('type', [
enforceAudioTrack: z.boolean(),
preferLossless: z.boolean(),
offthreadVideoCacheSizeInBytes: z.number().nullable(),
- colorSpace: z.enum(BrowserSafeApis.validColorSpaces),
+ colorSpace: z.enum(BrowserSafeApis.validColorSpaces).nullable(),
clientVersion: z.string(),
}),
z.object({
diff --git a/packages/example/src/test/stills-and-colorspaces.test.ts b/packages/example/src/test/stills-and-colorspaces.test.ts
index 143b1b1f26..2c83df5bc0 100644
--- a/packages/example/src/test/stills-and-colorspaces.test.ts
+++ b/packages/example/src/test/stills-and-colorspaces.test.ts
@@ -100,6 +100,7 @@ test(
const composition = await selectComposition({
serveUrl: bundled,
id: 'tiles',
+ inputProps: {},
});
const testOut = path.join(folder, `.${imageFormat}`);
@@ -127,6 +128,7 @@ test('Bt709 encoding should work', async () => {
const composition = await selectComposition({
serveUrl: bundled,
id: 'green',
+ inputProps: {},
});
const still = await renderStill({
@@ -151,7 +153,6 @@ test('Bt709 encoding should work', async () => {
codec: 'h264',
composition,
imageFormat: 'png',
- colorSpace: 'bt709',
serveUrl: bundled,
muted: true,
});
diff --git a/packages/it-tests/src/monorepo/go-package.test.ts b/packages/it-tests/src/monorepo/go-package.test.ts
index fea1fc6acb..8e3e970c4c 100644
--- a/packages/it-tests/src/monorepo/go-package.test.ts
+++ b/packages/it-tests/src/monorepo/go-package.test.ts
@@ -37,7 +37,7 @@ test("Go package should create the same payload as normal Lambda package", async
audioBitrate: null,
audioCodec: null,
chromiumOptions: {},
- colorSpace: "default",
+ colorSpace: null,
concurrencyPerLambda: 1,
crf: undefined,
deleteAfter: null,
diff --git a/packages/it-tests/src/monorepo/php-package.test.ts b/packages/it-tests/src/monorepo/php-package.test.ts
index b09f01ba42..b36e682d40 100644
--- a/packages/it-tests/src/monorepo/php-package.test.ts
+++ b/packages/it-tests/src/monorepo/php-package.test.ts
@@ -81,7 +81,7 @@ class Semantic
audioBitrate: null,
audioCodec: null,
chromiumOptions: {},
- colorSpace: "default",
+ colorSpace: null,
concurrencyPerLambda: 1,
crf: undefined,
deleteAfter: null,
diff --git a/packages/it-tests/src/monorepo/python-package.test.ts b/packages/it-tests/src/monorepo/python-package.test.ts
index 1b7426fa1c..32db5cdadf 100644
--- a/packages/it-tests/src/monorepo/python-package.test.ts
+++ b/packages/it-tests/src/monorepo/python-package.test.ts
@@ -53,7 +53,7 @@ test("Python package should create the same renderMedia payload as normal Lambda
audioBitrate: null,
audioCodec: null,
chromiumOptions: {},
- colorSpace: "default",
+ colorSpace: null,
concurrencyPerLambda: 1,
crf: undefined,
deleteAfter: null,
diff --git a/packages/it-tests/src/ssr/render-frames.test.ts b/packages/it-tests/src/ssr/render-frames.test.ts
index f7c83e6ce8..1e8572f8ef 100644
--- a/packages/it-tests/src/ssr/render-frames.test.ts
+++ b/packages/it-tests/src/ssr/render-frames.test.ts
@@ -16,6 +16,7 @@ test("Legacy SSR way of rendering videos should still work", async () => {
"https://661808694cad562ef2f35be7--incomparable-dasik-a4482b.netlify.app/",
{
puppeteerInstance,
+ inputProps: {},
}
);
diff --git a/packages/it-tests/src/ssr/render-media.test.ts b/packages/it-tests/src/ssr/render-media.test.ts
index 98fa0d92a0..f5edac959f 100644
--- a/packages/it-tests/src/ssr/render-media.test.ts
+++ b/packages/it-tests/src/ssr/render-media.test.ts
@@ -10,6 +10,7 @@ test("Render video with browser instance open", async () => {
"https://661808694cad562ef2f35be7--incomparable-dasik-a4482b.netlify.app/",
{
puppeteerInstance,
+ inputProps: {},
}
);
diff --git a/packages/it-tests/src/ssr/render-still.test.ts b/packages/it-tests/src/ssr/render-still.test.ts
index d2a9ec837e..e45b503ed5 100644
--- a/packages/it-tests/src/ssr/render-still.test.ts
+++ b/packages/it-tests/src/ssr/render-still.test.ts
@@ -19,6 +19,7 @@ test("Render video with browser instance open", async () => {
"https://661808694cad562ef2f35be7--incomparable-dasik-a4482b.netlify.app/",
{
puppeteerInstance,
+ inputProps: {}
}
);
diff --git a/packages/lambda/src/api/make-lambda-payload.ts b/packages/lambda/src/api/make-lambda-payload.ts
index bc1c23f487..16313db3a9 100644
--- a/packages/lambda/src/api/make-lambda-payload.ts
+++ b/packages/lambda/src/api/make-lambda-payload.ts
@@ -76,7 +76,7 @@ export type InnerRenderMediaOnLambdaInput = {
rendererFunctionName: string | null;
forceBucketName: string | null;
audioCodec: AudioCodec | null;
- colorSpace: ColorSpace;
+ colorSpace: ColorSpace | null;
deleteAfter: DeleteAfter | null;
indent: boolean;
} & ToOptions<typeof BrowserSafeApis.optionsMap.renderMediaOnLambda>;
@@ -188,7 +188,7 @@ export const makeLambdaRenderMediaPayload = async ({
type: LambdaRoutines.start,
offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,
deleteAfter: deleteAfter ?? null,
- colorSpace: colorSpace ?? 'default',
+ colorSpace: colorSpace ?? null,
preferLossless: preferLossless ?? false,
};
};
diff --git a/packages/lambda/src/api/render-media-on-lambda.ts b/packages/lambda/src/api/render-media-on-lambda.ts
index 4e9a902e35..7db33da832 100644
--- a/packages/lambda/src/api/render-media-on-lambda.ts
+++ b/packages/lambda/src/api/render-media-on-lambda.ts
@@ -126,7 +126,7 @@ export const renderMediaOnLambdaOptionalToRequired = (
audioCodec: options.audioCodec ?? null,
chromiumOptions: options.chromiumOptions ?? {},
codec: options.codec,
- colorSpace: options.colorSpace ?? 'default',
+ colorSpace: options.colorSpace ?? null,
composition: options.composition,
concurrencyPerLambda: options.concurrencyPerLambda ?? 1,
crf: options.crf,
diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.ts
index ef73692513..a732a005eb 100644
--- a/packages/lambda/src/shared/constants.ts
+++ b/packages/lambda/src/shared/constants.ts
@@ -281,7 +281,7 @@ export type LambdaStartPayload = {
bucketName: string | null;
offthreadVideoCacheSizeInBytes: number | null;
deleteAfter: DeleteAfter | null;
- colorSpace: ColorSpace;
+ colorSpace: ColorSpace | null;
preferLossless: boolean;
};
@@ -341,7 +341,7 @@ export type LambdaPayloads = {
forceWidth: number | null;
offthreadVideoCacheSizeInBytes: number | null;
deleteAfter: DeleteAfter | null;
- colorSpace: ColorSpace;
+ colorSpace: ColorSpace | null;
preferLossless: boolean;
};
status: LambdaStatusPayload;
@@ -387,7 +387,7 @@ export type LambdaPayloads = {
preferLossless: boolean;
offthreadVideoCacheSizeInBytes: number | null;
deleteAfter: DeleteAfter | null;
- colorSpace: ColorSpace;
+ colorSpace: ColorSpace | null;
compositionStart: number;
framesPerLambda: number;
};
diff --git a/packages/lambda/src/test/integration/renders/old-version.test.ts b/packages/lambda/src/test/integration/renders/old-version.test.ts
index cebc664c78..399f572b54 100644
--- a/packages/lambda/src/test/integration/renders/old-version.test.ts
+++ b/packages/lambda/src/test/integration/renders/old-version.test.ts
@@ -58,7 +58,7 @@ test('Should fail when using an incompatible version', async () => {
renderId: 'test',
offthreadVideoCacheSizeInBytes: null,
deleteAfter: null,
- colorSpace: 'default',
+ colorSpace: null,
preferLossless: false,
},
functionName: 'remotion-dev-render',
diff --git a/packages/lambda/src/test/integration/webhooks.test.ts b/packages/lambda/src/test/integration/webhooks.test.ts
index cd6f94b444..203d4da82f 100644
--- a/packages/lambda/src/test/integration/webhooks.test.ts
+++ b/packages/lambda/src/test/integration/webhooks.test.ts
@@ -109,7 +109,7 @@ describe('Webhooks', () => {
audioCodec: null,
offthreadVideoCacheSizeInBytes: null,
deleteAfter: null,
- colorSpace: 'default',
+ colorSpace: null,
preferLossless: false,
},
functionName: 'remotion-dev-lambda',
@@ -226,7 +226,7 @@ describe('Webhooks', () => {
rendererFunctionName: null,
audioCodec: null,
deleteAfter: null,
- colorSpace: 'default',
+ colorSpace: null,
preferLossless: false,
},
timeoutInTest: 1000,
diff --git a/packages/renderer/src/client.ts b/packages/renderer/src/client.ts
index 57bf7a84d6..0a13c9b6fe 100644
--- a/packages/renderer/src/client.ts
+++ b/packages/renderer/src/client.ts
@@ -21,7 +21,7 @@ import {
supportedAudioCodecs,
validAudioCodecs,
} from './options/audio-codec';
-import {validColorSpaces} from './options/color-space';
+import {DEFAULT_COLOR_SPACE, validColorSpaces} from './options/color-space';
import {validOpenGlRenderers} from './options/gl';
import {optionsMap} from './options/options-map';
import {getOutputCodecOrUndefined} from './options/video-codec';
@@ -52,6 +52,7 @@ export const BrowserSafeApis = {
DEFAULT_PIXEL_FORMAT,
DEFAULT_TIMEOUT,
DEFAULT_JPEG_QUALITY,
+ DEFAULT_COLOR_SPACE,
supportedAudioCodecs,
defaultFileExtensionMap,
defaultAudioCodecs,
diff --git a/packages/renderer/src/ffmpeg-args.ts b/packages/renderer/src/ffmpeg-args.ts
index 1d727dbc8f..2a39139c81 100644
--- a/packages/renderer/src/ffmpeg-args.ts
+++ b/packages/renderer/src/ffmpeg-args.ts
@@ -1,7 +1,7 @@
import type {Codec} from './codec';
import {validateQualitySettings} from './crf';
import {getCodecName} from './get-codec-name';
-import type {ColorSpace} from './options/color-space';
+import {DEFAULT_COLOR_SPACE, type ColorSpace} from './options/color-space';
import type {X264Preset} from './options/x264-preset';
import type {PixelFormat} from './pixel-format';
import {truthy} from './truthy';
@@ -70,7 +70,7 @@ export const generateFfmpegArgs = ({
videoBitrate: string | null;
encodingMaxRate: string | null;
encodingBufferSize: string | null;
- colorSpace: ColorSpace;
+ colorSpace: ColorSpace | null;
}): string[][] => {
const encoderName = getCodecName(codec);
@@ -78,8 +78,10 @@ export const generateFfmpegArgs = ({
throw new TypeError('encoderName is null: ' + JSON.stringify(codec));
}
+ const resolvedColorSpace = colorSpace ?? DEFAULT_COLOR_SPACE;
+
const colorSpaceOptions: string[][] =
- colorSpace === 'bt709'
+ resolvedColorSpace === 'bt709'
? [
['-colorspace:v', 'bt709'],
['-color_primaries:v', 'bt709'],
@@ -91,7 +93,7 @@ export const generateFfmpegArgs = ({
// "Color range" section
['-vf', 'zscale=matrix=709:matrixin=709:range=limited'],
]
- : colorSpace === 'bt2020-ncl'
+ : resolvedColorSpace === 'bt2020-ncl'
? [
['-colorspace:v', 'bt2020nc'],
['-color_primaries:v', 'bt2020'],
diff --git a/packages/renderer/src/options/color-space.tsx b/packages/renderer/src/options/color-space.tsx
index 1bb21f1f8e..3d7addee5c 100644
--- a/packages/renderer/src/options/color-space.tsx
+++ b/packages/renderer/src/options/color-space.tsx
@@ -1,10 +1,26 @@
+import {NoReactInternals} from 'remotion/no-react';
import type {AnyRemotionOption} from './option';
-export const validColorSpaces = ['default', 'bt709', 'bt2020-ncl'] as const;
+const validV4ColorSpaces = ['default', 'bt709', 'bt2020-ncl'] as const;
+const validV5ColorSpaces = ['bt601', 'bt709', 'bt2020-ncl'] as const;
+
+export const validColorSpaces = (
+ NoReactInternals.ENABLE_V5_BREAKING_CHANGES
+ ? validV5ColorSpaces
+ : validV4ColorSpaces
+) as true extends typeof NoReactInternals.ENABLE_V5_BREAKING_CHANGES
+ ? typeof validV5ColorSpaces
+ : typeof validV4ColorSpaces;
export type ColorSpace = (typeof validColorSpaces)[number];
-let colorSpace: ColorSpace = 'default';
+export const DEFAULT_COLOR_SPACE = (
+ NoReactInternals.ENABLE_V5_BREAKING_CHANGES ? 'bt709' : 'default'
+) as true extends typeof NoReactInternals.ENABLE_V5_BREAKING_CHANGES
+ ? 'bt709'
+ : 'default';
+
+let colorSpace: ColorSpace = DEFAULT_COLOR_SPACE;
const cliFlag = 'color-space' as const;
@@ -15,13 +31,24 @@ export const colorSpaceOption = {
<>
Color space to use for the video. Acceptable values:{' '}
<code>
- {'"'}default{'"'}
+ {'"'}
+ {DEFAULT_COLOR_SPACE}
+ {'"'}
</code>
- ,{' '}
- <code>
- {'"'}bt709{'"'}
- </code>{' '}
- (since v4.0.28),{' '}
+ (default since 5.0),{' '}
+ {NoReactInternals.ENABLE_V5_BREAKING_CHANGES ? (
+ <code>
+ {'"'}bt601{'"'}
+ {', '}
+ </code>
+ ) : (
+ <>
+ <code>
+ {'"'}bt709{'"'}
+ </code>{' '}
+ (since v4.0.28),{' '}
+ </>
+ )}
<code>
{'"'}bt2020-ncl{'"'}
</code>{' '}
@@ -30,18 +57,19 @@ export const colorSpaceOption = {
{'"'}bt2020-cl{'"'}
</code>{' '}
(since v4.0.88), .<br />
- If a non-default colorspace is used, it is recommended to also use{' '}
+ For best color accuracy, it is recommended to also use{' '}
<code>
{'"'}png{'"'}
</code>{' '}
as the image format to have accurate color transformations throughout.
+ <br />
Only since v4.0.83, colorspace conversion is actually performed,
previously it would only tag the metadata of the video.
</>
),
docLink: 'https://www.remotion.dev/docs/renderer/render-media#colorspace',
ssrName: 'colorSpace',
- type: 'default' as ColorSpace,
+ type: DEFAULT_COLOR_SPACE as ColorSpace | null,
getValue: ({commandLine}) => {
if (commandLine[cliFlag] !== undefined) {
return {
@@ -50,7 +78,7 @@ export const colorSpaceOption = {
};
}
- if (colorSpace !== 'default') {
+ if (colorSpace !== DEFAULT_COLOR_SPACE) {
return {
source: 'config',
value: colorSpace,
@@ -59,13 +87,13 @@ export const colorSpaceOption = {
return {
source: 'default',
- value: 'default',
+ value: DEFAULT_COLOR_SPACE,
};
},
setConfig: (value) => {
- colorSpace = value;
+ colorSpace = value ?? DEFAULT_COLOR_SPACE;
},
-} satisfies AnyRemotionOption<ColorSpace>;
+} satisfies AnyRemotionOption<ColorSpace | null>;
export const validateColorSpace = (option: unknown) => {
if (validColorSpaces.includes(option as ColorSpace)) {
diff --git a/packages/renderer/src/prespawn-ffmpeg.ts b/packages/renderer/src/prespawn-ffmpeg.ts
index ef1727b1b2..ecb4e04ce1 100644
--- a/packages/renderer/src/prespawn-ffmpeg.ts
+++ b/packages/renderer/src/prespawn-ffmpeg.ts
@@ -53,7 +53,7 @@ type PreStitcherOptions = {
encodingMaxRate: string | null;
encodingBufferSize: string | null;
indent: boolean;
- colorSpace: ColorSpace;
+ colorSpace: ColorSpace | null;
binariesDirectory: string | null;
};
diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.ts
index 9870f7927b..036726c83a 100644
--- a/packages/renderer/src/render-media.ts
+++ b/packages/renderer/src/render-media.ts
@@ -36,7 +36,7 @@ import type {CancelSignal} from './make-cancel-signal';
import {cancelErrorMessages, makeCancelSignal} from './make-cancel-signal';
import type {ChromiumOptions} from './open-browser';
import {isAudioCodec} from './options/audio-codec';
-import type {ColorSpace} from './options/color-space';
+import {DEFAULT_COLOR_SPACE, type ColorSpace} from './options/color-space';
import type {ToOptions} from './options/option';
import type {optionsMap} from './options/options-map';
import {validateSelectedCodecAndPresetCombination} from './options/x264-preset';
@@ -919,7 +919,7 @@ export const renderMedia = ({
data: composition.props ?? {},
}).serializedString,
offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,
- colorSpace: colorSpace ?? 'default',
+ colorSpace: colorSpace ?? DEFAULT_COLOR_SPACE,
repro: repro ?? false,
finishRenderProgress: () => undefined,
binariesDirectory: binariesDirectory ?? null,
diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.ts
index 74d176c35d..f01c5c8c36 100644
--- a/packages/renderer/src/stitch-frames-to-video.ts
+++ b/packages/renderer/src/stitch-frames-to-video.ts
@@ -23,7 +23,7 @@ import type {CancelSignal} from './make-cancel-signal';
import {cancelErrorMessages} from './make-cancel-signal';
import type {AudioCodec} from './options/audio-codec';
import {resolveAudioCodec} from './options/audio-codec';
-import type {ColorSpace} from './options/color-space';
+import {DEFAULT_COLOR_SPACE, type ColorSpace} from './options/color-space';
import type {ToOptions} from './options/option';
import type {optionsMap} from './options/options-map';
import type {X264Preset} from './options/x264-preset';
@@ -68,7 +68,7 @@ type InternalStitchFramesToVideoOptions = {
x264Preset: X264Preset | null;
enforceAudioTrack: boolean;
ffmpegOverride: null | FfmpegOverrideFn;
- colorSpace: ColorSpace;
+ colorSpace: ColorSpace | null;
binariesDirectory: string | null;
} & ToOptions<typeof optionsMap.stitchFramesToVideo>;
@@ -539,7 +539,7 @@ export const stitchFramesToVideo = ({
preEncodedFileLocation: null,
preferLossless: false,
x264Preset: x264Preset ?? null,
- colorSpace: colorSpace ?? 'default',
+ colorSpace: colorSpace ?? DEFAULT_COLOR_SPACE,
binariesDirectory: binariesDirectory ?? null,
separateAudioTo: separateAudioTo ?? null,
});