🎥 Make videos programmatically with React
color space
Jonny Burger5c8673590e43
diff --git a/packages/bundler/src/index-html.ts b/packages/bundler/src/index-html.tsindex 6c727fdc50..77088c948a 100644--- a/packages/bundler/src/index-html.ts+++ b/packages/bundler/src/index-html.ts@@ -28,6 +28,7 @@ export type RenderDefaults = {ignoreCertificateErrors: boolean;offthreadVideoCacheSizeInBytes: number | null;headless: boolean;+ colorSpace: string;};declare global {diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.tsindex 70e874f26b..a916494a16 100644--- a/packages/cli/src/benchmark.ts+++ b/packages/cli/src/benchmark.ts@@ -176,6 +176,7 @@ export const benchmarkCommand = async (concurrency: unparsedConcurrency,logLevel,offthreadVideoCacheSizeInBytes,+ colorSpace,} = await getCliOptions({isLambda: false,type: 'series',@@ -348,6 +349,7 @@ export const benchmarkCommand = async (staticBase: null,}).serializedString,offthreadVideoCacheSizeInBytes,+ colorSpace,},(run, progress) => {benchmarkProgress.update(diff --git a/packages/cli/src/config/color-space.ts b/packages/cli/src/config/color-space.tsnew file mode 100644index 0000000000..966bef148f--- /dev/null+++ b/packages/cli/src/config/color-space.ts@@ -0,0 +1,11 @@+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.tsindex 1a6cce6b6b..400dda7841 100644--- a/packages/cli/src/config/index.ts+++ b/packages/cli/src/config/index.ts@@ -39,6 +39,7 @@ import type {WebpackConfiguration} from '@remotion/bundler';import type {BrowserExecutable,CodecOrUndefined,+ ColorSpace,Crf,FrameRange,StillImageFormat,@@ -59,6 +60,7 @@ import {setChromiumOpenGlRenderer,} from './chromium-flags';import {setCodec} from './codec';+import {getColorSpace, setColorSpace} from './color-space';import type {Concurrency} from './concurrency';import {setConcurrency} from './concurrency';import {getCrfOrUndefined, setCrf} from './crf';@@ -393,6 +395,11 @@ declare global {* Mutually exclusive with setCrf().*/readonly setVideoBitrate: (bitrate: string | null) => void;++ /**+ * Opt into bt709 rendering.+ */+ readonly setColorSpace: (colorSpace: ColorSpace) => void;}}@@ -516,6 +523,7 @@ export const Config: FlatConfig = {overrideFfmpegCommand: setFfmpegOverrideFunction,setAudioCodec,setOffthreadVideoCacheSizeInBytes,+ setColorSpace,};export type {Concurrency, WebpackConfiguration, WebpackOverrideFn};@@ -571,4 +579,5 @@ export const ConfigInternals = {getShouldOpenBrowser,getChromiumUserAgent,getOffthreadVideoCacheSizeInBytes,+ getColorSpace,};diff --git a/packages/cli/src/editor/components/Modals.tsx b/packages/cli/src/editor/components/Modals.tsxindex 73ee123e13..51534e359f 100644--- a/packages/cli/src/editor/components/Modals.tsx+++ b/packages/cli/src/editor/components/Modals.tsx@@ -61,6 +61,7 @@ export const Modals: React.FC = () => {defaultProps={modalContextType.defaultProps}inFrameMark={modalContextType.inFrameMark}outFrameMark={modalContextType.outFrameMark}+ colorSpace={modalContextType.initialColorSpace}/>)}diff --git a/packages/cli/src/editor/components/RenderButton.tsx b/packages/cli/src/editor/components/RenderButton.tsxindex aebaf8f87c..8f284bf264 100644--- a/packages/cli/src/editor/components/RenderButton.tsx+++ b/packages/cli/src/editor/components/RenderButton.tsx@@ -1,6 +1,7 @@import type {AudioCodec,Codec,+ ColorSpace,LogLevel,OpenGlRenderer,PixelFormat,@@ -123,6 +124,7 @@ export const RenderButton: React.FC = () => {defaultProps: props[video.id] ?? video.defaultProps,inFrameMark: inFrame,outFrameMark: outFrame,+ initialColorSpace: defaults.colorSpace as ColorSpace,});}, [video, setSelectedModal, frame, props, inFrame, outFrame]);diff --git a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx b/packages/cli/src/editor/components/RenderModal/RenderModal.tsxindex 9c6e7c701f..7a4fd8e289 100644--- a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx+++ b/packages/cli/src/editor/components/RenderModal/RenderModal.tsx@@ -1,6 +1,7 @@import type {AudioCodec,Codec,+ ColorSpace,OpenGlRenderer,PixelFormat,ProResProfile,@@ -223,6 +224,7 @@ type RenderModalProps = {defaultProps: Record<string, unknown>;inFrameMark: number | null;outFrameMark: number | null;+ colorSpace: ColorSpace;};const RenderModal: React.FC<@@ -268,6 +270,7 @@ const RenderModal: React.FC<onClose,resolvedComposition,unresolvedComposition,+ colorSpace,}) => {const isMounted = useRef(true);@@ -700,6 +703,7 @@ const RenderModal: React.FC<envVariables: envVariablesArrayToObject(envVariables),inputProps,offthreadVideoCacheSizeInBytes,+ colorSpace,}).then(() => {dispatchIfMounted({type: 'succeed'});@@ -740,6 +744,7 @@ const RenderModal: React.FC<envVariables,inputProps,offthreadVideoCacheSizeInBytes,+ colorSpace,onClose,]);diff --git a/packages/cli/src/editor/components/RenderQueue/actions.ts b/packages/cli/src/editor/components/RenderQueue/actions.tsindex ef98c2c25f..af09f2face 100644--- a/packages/cli/src/editor/components/RenderQueue/actions.ts+++ b/packages/cli/src/editor/components/RenderQueue/actions.ts@@ -1,6 +1,7 @@import type {AudioCodec,Codec,+ ColorSpace,PixelFormat,ProResProfile,StillImageFormat,@@ -127,6 +128,7 @@ export const addVideoRenderJob = ({envVariables,inputProps,offthreadVideoCacheSizeInBytes,+ colorSpace,}: {compositionId: string;outName: string;@@ -155,6 +157,7 @@ export const addVideoRenderJob = ({envVariables: Record<string, string>;inputProps: Record<string, unknown>;offthreadVideoCacheSizeInBytes: number | null;+ colorSpace: ColorSpace;}) => {return callApi('/api/render', {compositionId,@@ -189,6 +192,7 @@ export const addVideoRenderJob = ({indent: undefined,}).serializedString,offthreadVideoCacheSizeInBytes,+ colorSpace,});};diff --git a/packages/cli/src/editor/components/SidebarRenderButton.tsx b/packages/cli/src/editor/components/SidebarRenderButton.tsxindex b96257721e..e4196c9003 100644--- a/packages/cli/src/editor/components/SidebarRenderButton.tsx+++ b/packages/cli/src/editor/components/SidebarRenderButton.tsx@@ -1,6 +1,7 @@import type {AudioCodec,Codec,+ ColorSpace,LogLevel,OpenGlRenderer,PixelFormat,@@ -101,6 +102,7 @@ export const SidebarRenderButton: React.FC<{defaultProps: props[composition.id] ?? composition.defaultProps,inFrameMark: null,outFrameMark: null,+ initialColorSpace: defaults.colorSpace as ColorSpace,});},[diff --git a/packages/cli/src/editor/state/modals.ts b/packages/cli/src/editor/state/modals.tsindex f0b34c5506..e9befcd29e 100644--- a/packages/cli/src/editor/state/modals.ts+++ b/packages/cli/src/editor/state/modals.ts@@ -1,6 +1,7 @@import type {AudioCodec,Codec,+ ColorSpace,OpenGlRenderer,PixelFormat,ProResProfile,@@ -47,6 +48,7 @@ export type RenderModalState = {initialIgnoreCertificateErrors: boolean;initialHeadless: boolean;initialOffthreadVideoCacheSizeInBytes: number | null;+ initialColorSpace: ColorSpace;minConcurrency: number;maxConcurrency: number;defaultProps: Record<string, unknown>;diff --git a/packages/cli/src/get-cli-options.ts b/packages/cli/src/get-cli-options.tsindex 75e2bea6a4..515d04e0ca 100644--- a/packages/cli/src/get-cli-options.ts+++ b/packages/cli/src/get-cli-options.ts@@ -172,5 +172,6 @@ export const getCliOptions = async (options: {configFileImageFormat: ConfigInternals.getUserPreferredVideoImageFormat(),offthreadVideoCacheSizeInBytes:ConfigInternals.getOffthreadVideoCacheSizeInBytes(),+ colorSpace: ConfigInternals.getColorSpace(),};};diff --git a/packages/cli/src/preview-server/render-queue/job.ts b/packages/cli/src/preview-server/render-queue/job.tsindex 9a5e612828..8ab5c91985 100644--- a/packages/cli/src/preview-server/render-queue/job.ts+++ b/packages/cli/src/preview-server/render-queue/job.ts@@ -1,6 +1,7 @@import type {AudioCodec,Codec,+ ColorSpace,makeCancelSignal,PixelFormat,ProResProfile,@@ -73,6 +74,7 @@ type RenderJobDynamicFields =numberOfGifLoops: number | null;disallowParallelEncoding: boolean;offthreadVideoCacheSizeInBytes: number | null;+ colorSpace: ColorSpace;} & RenderJobDynamicStatus);export type RenderJob = {@@ -124,6 +126,7 @@ type AddRenderRequestDynamicFields =everyNthFrame: number;numberOfGifLoops: number | null;disallowParallelEncoding: boolean;+ colorSpace: ColorSpace;};export type CancelRenderRequest = {diff --git a/packages/cli/src/preview-server/render-queue/make-retry-payload.ts b/packages/cli/src/preview-server/render-queue/make-retry-payload.tsindex 9287021567..1f3f1009e7 100644--- a/packages/cli/src/preview-server/render-queue/make-retry-payload.ts+++ b/packages/cli/src/preview-server/render-queue/make-retry-payload.ts@@ -1,6 +1,7 @@import type {AudioCodec,Codec,+ ColorSpace,PixelFormat,ProResProfile,X264Preset,@@ -61,6 +62,7 @@ export const makeRetryPayload = (job: RenderJob): RenderModalState => {inFrameMark: null,outFrameMark: null,initialOffthreadVideoCacheSizeInBytes: job.offthreadVideoCacheSizeInBytes,+ initialColorSpace: defaults.colorSpace as ColorSpace,};}@@ -110,6 +112,7 @@ export const makeRetryPayload = (job: RenderJob): RenderModalState => {inFrameMark: job.startFrame,outFrameMark: job.endFrame,initialOffthreadVideoCacheSizeInBytes: job.offthreadVideoCacheSizeInBytes,+ initialColorSpace: job.colorSpace,};}diff --git a/packages/cli/src/preview-server/render-queue/process-video.ts b/packages/cli/src/preview-server/render-queue/process-video.tsindex d9a66a6781..ea7a9e78f3 100644--- a/packages/cli/src/preview-server/render-queue/process-video.ts+++ b/packages/cli/src/preview-server/render-queue/process-video.ts@@ -74,5 +74,6 @@ export const processVideoJob = async ({audioCodec: job.audioCodec,disallowParallelEncoding: job.disallowParallelEncoding,offthreadVideoCacheSizeInBytes: job.offthreadVideoCacheSizeInBytes,+ colorSpace: job.colorSpace,});};diff --git a/packages/cli/src/preview-server/routes.ts b/packages/cli/src/preview-server/routes.tsindex 2484f2129e..fb0b657c5f 100644--- a/packages/cli/src/preview-server/routes.ts+++ b/packages/cli/src/preview-server/routes.ts@@ -78,6 +78,7 @@ const handleFallback = async ({const openGlRenderer = ConfigInternals.getChromiumOpenGlRenderer();const offthreadVideoCacheSizeInBytes =ConfigInternals.getOffthreadVideoCacheSizeInBytes();+ const colorSpace = ConfigInternals.getColorSpace();const maxConcurrency = RenderInternals.getMaxConcurrency();const minConcurrency = RenderInternals.getMinConcurrency();@@ -131,6 +132,7 @@ const handleFallback = async ({ignoreCertificateErrors,openGlRenderer,offthreadVideoCacheSizeInBytes,+ colorSpace,},publicFolderExists: existsSync(publicDir) ? publicDir : null,}),diff --git a/packages/cli/src/preview-server/routes/add-render.ts b/packages/cli/src/preview-server/routes/add-render.tsindex 3aa435fd34..67272f665a 100644--- a/packages/cli/src/preview-server/routes/add-render.ts+++ b/packages/cli/src/preview-server/routes/add-render.ts@@ -50,6 +50,7 @@ export const handleAddRender: ApiHandler<AddRenderRequest, undefined> = ({serializedInputPropsWithCustomSchema:input.serializedInputPropsWithCustomSchema,offthreadVideoCacheSizeInBytes: input.offthreadVideoCacheSizeInBytes,+ colorSpace: input.colorSpace,},});}diff --git a/packages/cli/src/render-flows/render.ts b/packages/cli/src/render-flows/render.tsindex 3e7e62bc0e..ee84a78aaa 100644--- a/packages/cli/src/render-flows/render.ts+++ b/packages/cli/src/render-flows/render.ts@@ -5,6 +5,7 @@ import type {CancelSignal,ChromiumOptions,Codec,+ ColorSpace,Crf,FfmpegOverrideFn,FrameRange,@@ -94,6 +95,7 @@ export const renderVideoFlow = async ({serializedInputPropsWithCustomSchema,disallowParallelEncoding,offthreadVideoCacheSizeInBytes,+ colorSpace,}: {remotionRoot: string;fullEntryPoint: string;@@ -139,6 +141,7 @@ export const renderVideoFlow = async ({audioCodec: AudioCodec | null;disallowParallelEncoding: boolean;offthreadVideoCacheSizeInBytes: number | null;+ colorSpace: ColorSpace;}) => {const downloads: DownloadProgress[] = [];@@ -484,6 +487,7 @@ export const renderVideoFlow = async ({staticBase: null,}).serializedString,offthreadVideoCacheSizeInBytes,+ colorSpace,});updateRenderProgress({newline: true, printToConsole: true});diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsxindex ada9e6dad4..ea0295e1f5 100644--- a/packages/cli/src/render.tsx+++ b/packages/cli/src/render.tsx@@ -64,6 +64,7 @@ export const render = async (remotionRoot: string, args: string[]) => {videoBitrate,numberOfGifLoops,offthreadVideoCacheSizeInBytes,+ colorSpace,} = await getCliOptions({isLambda: false,type: 'series',@@ -123,5 +124,6 @@ export const render = async (remotionRoot: string, args: string[]) => {audioCodec,disallowParallelEncoding: false,offthreadVideoCacheSizeInBytes,+ colorSpace,});};diff --git a/packages/cloudrun/src/api/render-media-on-cloudrun.ts b/packages/cloudrun/src/api/render-media-on-cloudrun.tsindex a3353ba9b6..523db96f67 100644--- a/packages/cloudrun/src/api/render-media-on-cloudrun.ts+++ b/packages/cloudrun/src/api/render-media-on-cloudrun.ts@@ -1,6 +1,7 @@import type {AudioCodec,ChromiumOptions,+ ColorSpace,FrameRange,LogLevel,PixelFormat,@@ -63,6 +64,7 @@ export type RenderMediaOnCloudrunInput = {concurrency?: number | string | null;enforceAudioTrack?: boolean;preferLossless?: boolean;+ colorSpace?: ColorSpace;} & Partial<ToOptions<typeof BrowserSafeApis.optionsMap.renderMediaOnLambda>>;const renderMediaOnCloudrunRaw = async ({@@ -101,6 +103,7 @@ const renderMediaOnCloudrunRaw = async ({enforceAudioTrack,preferLossless,offthreadVideoCacheSizeInBytes,+ colorSpace,}: RenderMediaOnCloudrunInput): Promise<RenderMediaOnCloudrunOutput | CloudRunCrashResponse> => {@@ -155,6 +158,7 @@ const renderMediaOnCloudrunRaw = async ({enforceAudioTrack: enforceAudioTrack ?? false,preferLossless: preferLossless ?? false,offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,+ colorSpace: colorSpace ?? 'default',};const client = await getAuthClientForUrl(cloudRunEndpoint);diff --git a/packages/cloudrun/src/functions/helpers/payloads.ts b/packages/cloudrun/src/functions/helpers/payloads.tsindex d3599d4d35..cdeb8758b5 100644--- a/packages/cloudrun/src/functions/helpers/payloads.ts+++ b/packages/cloudrun/src/functions/helpers/payloads.ts@@ -52,6 +52,7 @@ export const CloudRunPayload = z.discriminatedUnion('type', [enforceAudioTrack: z.boolean(),preferLossless: z.boolean(),offthreadVideoCacheSizeInBytes: z.number().nullable(),+ colorSpace: z.enum(BrowserSafeApis.validColorSpaces),}),z.object({type: z.literal('still'),diff --git a/packages/cloudrun/src/functions/render-media-single-thread.ts b/packages/cloudrun/src/functions/render-media-single-thread.tsindex 58d1ff827b..6a38d8522e 100644--- a/packages/cloudrun/src/functions/render-media-single-thread.ts+++ b/packages/cloudrun/src/functions/render-media-single-thread.ts@@ -97,6 +97,7 @@ export const renderMediaSingleThread = async (puppeteerInstance: undefined,server: undefined,offthreadVideoCacheSizeInBytes: body.offthreadVideoCacheSizeInBytes,+ colorSpace: body.colorSpace,});const storage = new Storage();diff --git a/packages/lambda/src/api/make-lambda-payload.ts b/packages/lambda/src/api/make-lambda-payload.tsindex b518db78fc..c62793a775 100644--- a/packages/lambda/src/api/make-lambda-payload.ts+++ b/packages/lambda/src/api/make-lambda-payload.ts@@ -53,6 +53,7 @@ export const makeLambdaRenderMediaPayload = async ({jpegQuality,quality,offthreadVideoCacheSizeInBytes,+ colorSpace,}: RenderMediaOnLambdaInput): Promise<LambdaStartPayload> => {if (quality) {throw new Error(@@ -121,6 +122,7 @@ export const makeLambdaRenderMediaPayload = async ({audioCodec: audioCodec ?? null,type: LambdaRoutines.start,offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,+ colorSpace: colorSpace ?? 'default',};};diff --git a/packages/lambda/src/api/render-media-on-lambda.ts b/packages/lambda/src/api/render-media-on-lambda.tsindex aed0b6f668..89e09fcf7d 100644--- a/packages/lambda/src/api/render-media-on-lambda.ts+++ b/packages/lambda/src/api/render-media-on-lambda.ts@@ -1,6 +1,7 @@import type {AudioCodec,ChromiumOptions,+ ColorSpace,FrameRange,LogLevel,PixelFormat,@@ -65,6 +66,7 @@ export type RenderMediaOnLambdaInput = {* @deprecated in favor of `logLevel`: true*/dumpBrowserLogs?: boolean;+ colorSpace?: ColorSpace;} & Partial<ToOptions<typeof BrowserSafeApis.optionsMap.renderMediaOnLambda>>;export type RenderMediaOnLambdaOutput = {diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.tsindex f152902892..70e78ea11d 100644--- a/packages/lambda/src/functions/launch.ts+++ b/packages/lambda/src/functions/launch.ts@@ -272,6 +272,7 @@ const innerLaunchHandler = async (},resolvedProps: serializedResolvedProps,offthreadVideoCacheSizeInBytes: params.offthreadVideoCacheSizeInBytes,+ colorSpace: params.colorSpace,};return payload;});diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.tsindex 3686b57cfb..97c81dcda7 100644--- a/packages/lambda/src/functions/renderer.ts+++ b/packages/lambda/src/functions/renderer.ts@@ -212,6 +212,7 @@ const renderHandler = async (server: undefined,serializedResolvedPropsWithCustomSchema: resolvedProps,offthreadVideoCacheSizeInBytes: params.offthreadVideoCacheSizeInBytes,+ colorSpace: params.colorSpace,}).then(({slowestFrames}) => {console.log(`Slowest frames:`);diff --git a/packages/lambda/src/functions/start.ts b/packages/lambda/src/functions/start.tsindex 342f6f0fbd..e6cc8aa663 100644--- a/packages/lambda/src/functions/start.ts+++ b/packages/lambda/src/functions/start.ts@@ -95,6 +95,7 @@ export const startHandler = async (params: LambdaPayload, options: Options) => {rendererFunctionName: params.rendererFunctionName,audioCodec: params.audioCodec,offthreadVideoCacheSizeInBytes: params.offthreadVideoCacheSizeInBytes,+ colorSpace: params.colorSpace,};// Don't replace with callLambda(), we want to return before the render is snonediff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.tsindex 4bd2ab3278..1bc3d3c64a 100644--- a/packages/lambda/src/shared/constants.ts+++ b/packages/lambda/src/shared/constants.ts@@ -2,6 +2,7 @@ import type {AudioCodec,ChromiumOptions,Codec,+ ColorSpace,FrameRange,LogLevel,PixelFormat,@@ -271,6 +272,7 @@ export type LambdaStartPayload = {forceWidth: number | null;bucketName: string | null;offthreadVideoCacheSizeInBytes: number | null;+ colorSpace: ColorSpace;};export type LambdaStatusPayload = {@@ -324,6 +326,7 @@ export type LambdaPayloads = {forceHeight: number | null;forceWidth: number | null;offthreadVideoCacheSizeInBytes: number | null;+ colorSpace: ColorSpace;};status: LambdaStatusPayload;renderer: {@@ -364,6 +367,7 @@ export type LambdaPayloads = {version: string;};offthreadVideoCacheSizeInBytes: number | null;+ colorSpace: ColorSpace;};still: {type: LambdaRoutines.still;diff --git a/packages/lambda/src/test/integration/renders/gif.test.ts b/packages/lambda/src/test/integration/renders/gif.test.tsindex 76986a3d83..60459b657c 100644--- a/packages/lambda/src/test/integration/renders/gif.test.ts+++ b/packages/lambda/src/test/integration/renders/gif.test.ts@@ -64,6 +64,7 @@ test('Should make a distributed GIF', async () => {bucketName: null,audioCodec: null,offthreadVideoCacheSizeInBytes: null,+ colorSpace: 'default',},functionName: 'remotion-dev-lambda',receivedStreamingPayload: () => undefined,diff --git a/packages/lambda/src/test/integration/renders/old-version.test.ts b/packages/lambda/src/test/integration/renders/old-version.test.tsindex 3d9c577ba9..abadf14129 100644--- a/packages/lambda/src/test/integration/renders/old-version.test.ts+++ b/packages/lambda/src/test/integration/renders/old-version.test.ts@@ -62,6 +62,7 @@ test('Should fail when using an incompatible version', async () => {audioCodec: null,renderId: 'test',offthreadVideoCacheSizeInBytes: null,+ colorSpace: 'default',},functionName: 'remotion-dev-render',receivedStreamingPayload: () => undefined,diff --git a/packages/lambda/src/test/integration/renders/other-bucket.test.ts b/packages/lambda/src/test/integration/renders/other-bucket.test.tsindex dcfa3bdaec..a18f281025 100644--- a/packages/lambda/src/test/integration/renders/other-bucket.test.ts+++ b/packages/lambda/src/test/integration/renders/other-bucket.test.ts@@ -67,6 +67,7 @@ test('Should be able to render to another bucket', async () => {bucketName: null,audioCodec: null,offthreadVideoCacheSizeInBytes: null,+ colorSpace: 'default',},functionName: 'remotion-dev-render',receivedStreamingPayload: () => undefined,diff --git a/packages/lambda/src/test/integration/renders/silent-audio.test.ts b/packages/lambda/src/test/integration/renders/silent-audio.test.tsindex 63bb14b7a1..5b8335aa57 100644--- a/packages/lambda/src/test/integration/renders/silent-audio.test.ts+++ b/packages/lambda/src/test/integration/renders/silent-audio.test.ts@@ -63,6 +63,7 @@ test('Should add silent audio if there is no audio', async () => {bucketName: null,audioCodec: null,offthreadVideoCacheSizeInBytes: null,+ colorSpace: 'default',},functionName: 'remotion-dev-render',receivedStreamingPayload: () => undefined,diff --git a/packages/lambda/src/test/integration/renders/transparent-webm.test.ts b/packages/lambda/src/test/integration/renders/transparent-webm.test.tsindex de7c595de1..b87f4e5140 100644--- a/packages/lambda/src/test/integration/renders/transparent-webm.test.ts+++ b/packages/lambda/src/test/integration/renders/transparent-webm.test.ts@@ -67,6 +67,7 @@ test('Should make a transparent video', async () => {bucketName: null,audioCodec: null,offthreadVideoCacheSizeInBytes: null,+ colorSpace: 'default',},functionName: 'remotion-dev-render',receivedStreamingPayload: () => undefined,diff --git a/packages/lambda/src/test/integration/webhooks.test.ts b/packages/lambda/src/test/integration/webhooks.test.tsindex 3c7f315245..459c1877b0 100644--- a/packages/lambda/src/test/integration/webhooks.test.ts+++ b/packages/lambda/src/test/integration/webhooks.test.ts@@ -106,6 +106,7 @@ describe('Webhooks', () => {bucketName: null,audioCodec: null,offthreadVideoCacheSizeInBytes: null,+ colorSpace: 'default',},functionName: 'remotion-dev-lambda',receivedStreamingPayload: () => undefined,@@ -202,6 +203,7 @@ describe('Webhooks', () => {forceWidth: null,rendererFunctionName: null,audioCodec: null,+ colorSpace: 'default',},timeoutInTest: 1000,retriesRemaining: 0,diff --git a/packages/renderer/src/client.ts b/packages/renderer/src/client.tsindex 4e486291a2..f7568ffb21 100644--- a/packages/renderer/src/client.ts+++ b/packages/renderer/src/client.ts@@ -16,6 +16,7 @@ import {} from './get-extension-from-codec';import {isAudioCodec} from './is-audio-codec';import {audioBitrateOption} from './options/audio-bitrate';+import {validColorSpaces} from './options/color-space';import {crfOption} from './options/crf';import {enforceAudioOption} from './options/enforce-audio';import {jpegQualityOption} from './options/jpeg-quality';@@ -59,6 +60,7 @@ export const BrowserSafeApis = {offthreadVideoCacheSizeInBytesOption,webhookCustomDataOption,},+ validColorSpaces,optionsMap,codecSupportsCrf,codecSupportsVideoBitrate,diff --git a/packages/renderer/src/ffmpeg-args.ts b/packages/renderer/src/ffmpeg-args.tsindex 52219f3ec9..55268cceb8 100644--- a/packages/renderer/src/ffmpeg-args.ts+++ b/packages/renderer/src/ffmpeg-args.ts@@ -1,6 +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 type {PixelFormat} from './pixel-format';import {truthy} from './truthy';import type {X264Preset} from './x264-preset';@@ -50,6 +51,7 @@ export const generateFfmpegArgs = ({codec,crf,videoBitrate,+ colorSpace,}: {hasPreencoded: boolean;proResProfileName: string | null;@@ -58,6 +60,7 @@ export const generateFfmpegArgs = ({crf: unknown;codec: Codec;videoBitrate: string | null | undefined;+ colorSpace: ColorSpace;}): string[][] => {const encoderName = getCodecName(codec);@@ -65,14 +68,21 @@ export const generateFfmpegArgs = ({throw new TypeError('encoderName is null: ' + JSON.stringify(codec));}+ const colorSpaceOptions: string[][] =+ colorSpace === 'bt709'+ ? [+ ['-colorspace:v', 'bt709'],+ ['-color_primaries:v', 'bt709'],+ ['-color_trc:v', 'bt709'],+ ['-color_range:v', 'tv'],+ ]+ : [];+return [+ ['-c:v', encoderName],// -c:v is the same as -vcodec as -codec:video// and specified the video codec.- ['-c:v', encoderName],- ['-colorspace:v', 'bt709'],- ['-color_primaries:v', 'bt709'],- ['-color_trc:v', 'bt709'],- ['-color_range:v', 'tv'],+ ...colorSpaceOptions,...firstEncodingStepOnly({codec,crf,diff --git a/packages/renderer/src/options/color-space.tsx b/packages/renderer/src/options/color-space.tsxindex 73841273d2..8eece0dcff 100644--- a/packages/renderer/src/options/color-space.tsx+++ b/packages/renderer/src/options/color-space.tsx@@ -1,6 +1,6 @@import {AnyRemotionOption} from './option';-const validColorSpaces = ['default', 'bt709'] as const;+export const validColorSpaces = ['default', 'bt709'] as const;export type ColorSpace = (typeof validColorSpaces)[number];diff --git a/packages/renderer/src/prespawn-ffmpeg.ts b/packages/renderer/src/prespawn-ffmpeg.tsindex 778aaad1c5..c86e87c908 100644--- a/packages/renderer/src/prespawn-ffmpeg.ts+++ b/packages/renderer/src/prespawn-ffmpeg.ts@@ -8,6 +8,7 @@ import type {VideoImageFormat} from './image-format';import type {LogLevel} from './log-level';import {Log} from './logger';import type {CancelSignal} from './make-cancel-signal';+import type {ColorSpace} from './options/color-space';import {parseFfmpegProgress} from './parse-ffmpeg-progress';import type {PixelFormat} from './pixel-format';import {@@ -50,6 +51,7 @@ type PreStitcherOptions = {signal: CancelSignal;videoBitrate: string | null;indent: boolean;+ colorSpace: ColorSpace;};export const prespawnFfmpeg = (options: PreStitcherOptions) => {@@ -95,6 +97,7 @@ export const prespawnFfmpeg = (options: PreStitcherOptions) => {codec,crf: options.crf,videoBitrate: options.videoBitrate,+ colorSpace: options.colorSpace,}),'-y',diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.tsindex d00cb05c9b..ac439d9471 100644--- a/packages/renderer/src/render-media.ts+++ b/packages/renderer/src/render-media.ts@@ -37,6 +37,7 @@ import {getLogLevel, Log} from './logger';import type {CancelSignal} from './make-cancel-signal';import {cancelErrorMessages, makeCancelSignal} from './make-cancel-signal';import type {ChromiumOptions} from './open-browser';+import type {ColorSpace} from './options/color-space';import type {ToOptions} from './options/option';import type {optionsMap} from './options/options-map';import {DEFAULT_OVERWRITE} from './overwrite';@@ -124,6 +125,7 @@ export type InternalRenderMediaOptions = {audioCodec: AudioCodec | null;serveUrl: string;concurrency: number | string | null;+ colorSpace: ColorSpace;} & ToOptions<typeof optionsMap.renderMedia>;export type RenderMediaOptions = {@@ -177,6 +179,7 @@ export type RenderMediaOptions = {concurrency?: number | string | null;logLevel?: LogLevel;offthreadVideoCacheSizeInBytes?: number | null;+ colorSpace?: ColorSpace;};type Await<T> = T extends PromiseLike<infer U> ? U : T;@@ -229,6 +232,7 @@ const internalRenderMediaRaw = ({logLevel,serializedResolvedPropsWithCustomSchema,offthreadVideoCacheSizeInBytes,+ colorSpace,}: InternalRenderMediaOptions): Promise<RenderMediaResult> => {validateJpegQuality(jpegQuality);validateQualitySettings({crf, codec, videoBitrate});@@ -427,6 +431,8 @@ const internalRenderMediaRaw = ({ffmpegOverride: ffmpegOverride ?? (({args}) => args),videoBitrate,indent,+ x264Preset: x264Preset ?? null,+ colorSpace,});stitcherFfmpeg = preStitcher.task;}@@ -630,6 +636,7 @@ const internalRenderMediaRaw = ({videoBitrate,audioCodec,x264Preset: x264Preset ?? null,+ colorSpace,}),stitchStart,]);@@ -747,6 +754,7 @@ export const renderMedia = ({quality,logLevel,offthreadVideoCacheSizeInBytes,+ colorSpace,}: RenderMediaOptions): Promise<RenderMediaResult> => {if (quality !== undefined) {console.warn(@@ -806,5 +814,6 @@ export const renderMedia = ({data: composition.props ?? {},}).serializedString,offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,+ colorSpace: colorSpace ?? 'default',});};diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.tsindex 6291f38d31..0dbd436eed 100644--- a/packages/renderer/src/stitch-frames-to-video.ts+++ b/packages/renderer/src/stitch-frames-to-video.ts@@ -31,6 +31,7 @@ import {Log} from './logger';import type {CancelSignal} from './make-cancel-signal';import {cancelErrorMessages} from './make-cancel-signal';import {mergeAudioTrack} from './merge-audio-track';+import type {ColorSpace} from './options/color-space';import {parseFfmpegProgress} from './parse-ffmpeg-progress';import type {PixelFormat} from './pixel-format';import {@@ -79,6 +80,7 @@ type InternalStitchFramesToVideoOptions = {x264Preset: X264Preset | null;enforceAudioTrack: boolean;ffmpegOverride: null | FfmpegOverrideFn;+ colorSpace: ColorSpace;};export type StitchFramesToVideoOptions = {@@ -105,6 +107,7 @@ export type StitchFramesToVideoOptions = {enforceAudioTrack?: boolean;ffmpegOverride?: FfmpegOverrideFn;x264Preset?: X264Preset | null;+ colorSpace?: ColorSpace;};type ReturnType = {@@ -222,6 +225,7 @@ const innerStitchFramesToVideo = async (numberOfGifLoops,onProgress,x264Preset,+ colorSpace,}: InternalStitchFramesToVideoOptions,remotionRoot: string,): Promise<ReturnType> => {@@ -420,6 +424,7 @@ const innerStitchFramesToVideo = async (proResProfileName,pixelFormat,x264Preset,+ colorSpace,}),codec === 'h264' ? ['-movflags', 'faststart'] : null,resolvedAudioCodec@@ -565,6 +570,7 @@ export const stitchFramesToVideo = ({verbose,videoBitrate,x264Preset,+ colorSpace,}: StitchFramesToVideoOptions): Promise<Buffer | null> => {return internalStitchFramesToVideo({assetsInfo,@@ -593,5 +599,6 @@ export const stitchFramesToVideo = ({preEncodedFileLocation: null,preferLossless: false,x264Preset: x264Preset ?? null,+ colorSpace: colorSpace ?? 'default',});};