🎥 Make videos programmatically with React
achieve full SSR modal feature parity with read-only mode
Igor Samokhovets48d000dc4560
diff --git a/packages/studio/src/components/RenderModal/RenderModalBasic.tsx b/packages/studio/src/components/RenderModal/RenderModalBasic.tsxindex e78d2c2227..4668f9ed56 100644--- a/packages/studio/src/components/RenderModal/RenderModalBasic.tsx+++ b/packages/studio/src/components/RenderModal/RenderModalBasic.tsx@@ -46,6 +46,7 @@ export const RenderModalBasic: React.FC<{readonly validationMessage: string | null;readonly setVerboseLogging: React.Dispatch<React.SetStateAction<LogLevel>>;readonly logLevel: LogLevel;+ readonly showOutputName: boolean;}> = ({renderMode,imageFormatOptions,@@ -65,6 +66,7 @@ export const RenderModalBasic: React.FC<{validationMessage,setVerboseLogging,logLevel,+ showOutputName,}) => {const existence = useFileExistence(outName);const videoCodecOptions = useMemo((): ComboboxValue[] => {@@ -220,14 +222,16 @@ export const RenderModalBasic: React.FC<{startFrame={startFrame}/>)}- <RenderModalOutputName- existence={existence}- inputStyle={input}- outName={outName}- onValueChange={onValueChange}- validationMessage={validationMessage}- label={renderMode === 'sequence' ? 'Folder name' : 'Output name'}- />+ {showOutputName ? (+ <RenderModalOutputName+ existence={existence}+ inputStyle={input}+ outName={outName}+ onValueChange={onValueChange}+ validationMessage={validationMessage}+ label={renderMode === 'sequence' ? 'Folder name' : 'Output name'}+ />+ ) : null}<div style={optionRow}><div style={label}>Log Level <Spacing x={0.5} />diff --git a/packages/studio/src/components/RenderModal/ServerRenderModal.tsx b/packages/studio/src/components/RenderModal/ServerRenderModal.tsxindex 10b1819cd5..a484a619db 100644--- a/packages/studio/src/components/RenderModal/ServerRenderModal.tsx+++ b/packages/studio/src/components/RenderModal/ServerRenderModal.tsx@@ -1173,58 +1173,128 @@ const RenderModal: React.FC<remotionVersion: window.remotion_version,locationHref: window.location.href,compositionId: resolvedComposition.id,+ outName,renderMode,renderDefaults,durationInFrames: resolvedComposition.durationInFrames,+ concurrency,frame,startFrame,endFrame,stillImageFormat,sequenceImageFormat,videoImageFormat,+ jpegQuality:+ renderMode === 'video'+ ? stillImageFormat === 'jpeg'+ ? jpegQuality+ : null+ : renderMode === 'audio'+ ? null+ : jpegQuality,codec,muted,enforceAudioTrack,proResProfile,x264Preset,pixelFormat,+ crf:+ qualityControlType === 'crf' &&+ hardwareAcceleration !== 'if-possible' &&+ hardwareAcceleration !== 'required'+ ? crf+ : null,+ videoBitrate,+ audioBitrate,+ audioCodec,+ everyNthFrame,+ numberOfGifLoops,+ disallowParallelEncoding,+ encodingBufferSize,+ encodingMaxRate,+ forSeamlessAacConcatenation,+ separateAudioTo,colorSpace,scale,logLevel,delayRenderTimeout,hardwareAcceleration,chromeMode,+ headless,+ disableWebSecurity,+ ignoreCertificateErrors,+ gl: openGlOption === 'default' ? null : openGlOption,+ userAgent,+ multiProcessOnLinux,+ darkMode,+ offthreadVideoCacheSizeInBytes,+ offthreadVideoThreads,+ mediaCacheSizeInBytes,+ beepOnFinish,+ repro,+ metadata,+ envVariables: envVariablesArrayToObject(envVariables),inputProps,});}, [+ audioBitrate,+ audioCodec,+ beepOnFinish,chromeMode,codec,colorSpace,+ concurrency,+ crf,+ darkMode,delayRenderTimeout,+ disableWebSecurity,+ disallowParallelEncoding,endFrame,+ encodingBufferSize,+ encodingMaxRate,enforceAudioTrack,+ envVariables,+ everyNthFrame,frame,+ forSeamlessAacConcatenation,hardwareAcceleration,+ headless,+ ignoreCertificateErrors,inputProps,+ jpegQuality,logLevel,+ mediaCacheSizeInBytes,+ metadata,+ multiProcessOnLinux,muted,+ numberOfGifLoops,+ offthreadVideoCacheSizeInBytes,+ offthreadVideoThreads,+ openGlOption,+ outName,pixelFormat,proResProfile,+ qualityControlType,readOnlyStudio,renderDefaults,renderMode,+ repro,resolvedComposition.durationInFrames,resolvedComposition.id,scale,+ separateAudioTo,sequenceImageFormat,startFrame,stillImageFormat,+ userAgent,videoImageFormat,+ videoBitrate,x264Preset,]);const [commandCopiedAt, setCommandCopiedAt] = useState<number | null>(null);- const renderDisabled =- !outnameValidation.valid || (!readOnlyStudio && state.type === 'load');+ const renderDisabled = readOnlyStudio+ ? false+ : !outnameValidation.valid || state.type === 'load';const trigger = useCallback(() => {if (readOnlyStudio) {@@ -1426,6 +1496,7 @@ const RenderModal: React.FC<setStartFrame={setStartFrame}setVerboseLogging={setLogLevel}logLevel={logLevel}+ showOutputName={!readOnlyStudio}startFrame={startFrame}validationMessage={outnameValidation.valid ? null : outnameValidation.error.messagediff --git a/packages/studio/src/helpers/make-render-command.ts b/packages/studio/src/helpers/make-render-command.tsindex b3654d6197..824be3f67d 100644--- a/packages/studio/src/helpers/make-render-command.ts+++ b/packages/studio/src/helpers/make-render-command.ts@@ -1,6 +1,11 @@+import type {+ RenderFramesOptions,+ RenderMediaOptions,+ RenderStillOptions,+} from '@remotion/renderer';import {BrowserSafeApis} from '@remotion/renderer/client';import type {RenderDefaults} from '@remotion/studio-shared';-import type {_InternalTypes} from 'remotion';+import type {renderMediaOnWeb} from '@remotion/web-renderer';type RenderMode = 'still' | 'video' | 'audio' | 'sequence';@@ -11,7 +16,7 @@ const shellQuote = (value: string) => {const addFlagWithValue = (flags: string[],flag: string,- value: string | number | null | undefined,+ value: string | number | boolean | null | undefined,) => {if (value === null || value === undefined) {return;@@ -26,6 +31,56 @@ const addBooleanFlag = (flags: string[], flag: string, value: boolean) => {}};+type ValueFlagMapping = {+ flag: string;+ value: string | number | boolean | null | undefined;+ defaultValue: string | number | boolean | null | undefined;+};++type BooleanFlagMapping = {+ flag: string;+ value: boolean;+ defaultValue: boolean;+};++const valueFlag = (+ flag: string,+ value: ValueFlagMapping['value'],+ defaultValue: ValueFlagMapping['defaultValue'],+): ValueFlagMapping => {+ return {flag, value, defaultValue};+};++const booleanFlag = (+ flag: string,+ value: boolean,+ defaultValue: boolean,+): BooleanFlagMapping => {+ return {flag, value, defaultValue};+};++const addValueFlagsIfChanged = (+ flags: string[],+ mappings: ValueFlagMapping[],+) => {+ for (const mapping of mappings) {+ if (mapping.value !== mapping.defaultValue) {+ addFlagWithValue(flags, mapping.flag, mapping.value);+ }+ }+};++const addTrueBooleanFlagsIfChanged = (+ flags: string[],+ mappings: BooleanFlagMapping[],+) => {+ for (const mapping of mappings) {+ if (mapping.value && mapping.value !== mapping.defaultValue) {+ addBooleanFlag(flags, mapping.flag, true);+ }+ }+};+export const getNpmRemotionCommandPrefix = (version: string) => {return version.trim() === ''? 'npx -p @remotion/cli remotion'@@ -58,110 +113,295 @@ export const normalizeServeUrlForRenderCommand = ({return `${parsed.origin}${parsed.pathname === '/' ? '' : parsed.pathname}`;};+const trimDefaultOutPrefix = (outName: string) => {+ if (outName.startsWith('out/')) {+ const trimmed = outName.slice('out/'.length);+ return trimmed.length === 0 ? outName : trimmed;+ }++ if (outName.startsWith('./out/')) {+ const trimmed = outName.slice('./out/'.length);+ return trimmed.length === 0 ? outName : trimmed;+ }++ return outName;+};++const getRenderMediaFlag = (+ option: keyof typeof BrowserSafeApis.optionsMap.renderMedia,+) => {+ return BrowserSafeApis.optionsMap.renderMedia[option].cliFlag;+};++const renderMediaValueFlag = (+ option: keyof typeof BrowserSafeApis.optionsMap.renderMedia,+ value: ValueFlagMapping['value'],+ defaultValue: ValueFlagMapping['defaultValue'],+): ValueFlagMapping => {+ return valueFlag(getRenderMediaFlag(option), value, defaultValue);+};++const renderMediaBooleanFlag = (+ option: keyof typeof BrowserSafeApis.optionsMap.renderMedia,+ value: boolean,+ defaultValue: boolean,+): BooleanFlagMapping => {+ return booleanFlag(getRenderMediaFlag(option), value, defaultValue);+};++type StrictRequired<T> = {+ [K in keyof T]-?: Exclude<T[K], undefined>;+};++type RenderMediaCommandOptions = Omit<+ StrictRequired<+ Pick<+ RenderMediaOptions,+ | 'codec'+ | 'crf'+ | 'concurrency'+ | 'disallowParallelEncoding'+ | 'muted'+ | 'enforceAudioTrack'+ | 'everyNthFrame'+ | 'numberOfGifLoops'+ | 'colorSpace'+ | 'scale'+ | 'logLevel'+ | 'repro'+ | 'metadata'+ | 'jpegQuality'+ | 'pixelFormat'+ | 'proResProfile'+ | 'x264Preset'+ | 'audioCodec'+ | 'forSeamlessAacConcatenation'+ | 'separateAudioTo'+ | 'hardwareAcceleration'+ | 'chromeMode'+ | 'offthreadVideoCacheSizeInBytes'+ | 'offthreadVideoThreads'+ | 'mediaCacheSizeInBytes'+ | 'audioBitrate'+ | 'videoBitrate'+ | 'encodingMaxRate'+ | 'encodingBufferSize'+ >+ >,+ | 'audioBitrate'+ | 'videoBitrate'+ | 'encodingMaxRate'+ | 'encodingBufferSize'+ | 'jpegQuality'+ | 'proResProfile'+> & {+ // Studio currently stores these as freeform strings.+ audioBitrate: string | null;+ videoBitrate: string | null;+ encodingMaxRate: string | null;+ encodingBufferSize: string | null;+ jpegQuality: Exclude<RenderMediaOptions['jpegQuality'], undefined> | null;+ proResProfile: Exclude<RenderMediaOptions['proResProfile'], undefined> | null;+};++type RenderStillCommandOptions = StrictRequired<+ Pick<RenderStillOptions, 'frame'>+>;+type RenderFramesSharedOptions = StrictRequired<+ Pick<+ RenderFramesOptions,+ 'concurrency' | 'everyNthFrame' | 'scale' | 'logLevel'+ >+>;+type RenderMediaOnWebInput = Parameters<typeof renderMediaOnWeb>[0];+type CrossRendererOptions = StrictRequired<+ Pick<RenderMediaOnWebInput, 'muted' | 'scale' | 'logLevel'>+>;++type ReadOnlyStudioRenderCommandInput = RenderMediaCommandOptions &+ RenderStillCommandOptions &+ RenderFramesSharedOptions &+ CrossRendererOptions & {+ remotionVersion: string;+ locationHref: string;+ compositionId: string;+ outName: string;+ renderMode: RenderMode;+ renderDefaults: RenderDefaults;+ durationInFrames: number;+ startFrame: number;+ endFrame: number;+ stillImageFormat: RenderDefaults['stillImageFormat'];+ sequenceImageFormat: RenderDefaults['videoImageFormat'];+ videoImageFormat: RenderDefaults['videoImageFormat'];+ delayRenderTimeout: number;+ headless: boolean;+ disableWebSecurity: boolean;+ ignoreCertificateErrors: boolean;+ gl: RenderDefaults['openGlRenderer'];+ userAgent: string | null;+ multiProcessOnLinux: boolean;+ darkMode: boolean;+ beepOnFinish: boolean;+ envVariables: Record<string, string>;+ inputProps: Record<string, unknown>;+ };+export const makeReadOnlyStudioRenderCommand = ({remotionVersion,locationHref,compositionId,+ outName,renderMode,renderDefaults,durationInFrames,+ concurrency,frame,startFrame,endFrame,stillImageFormat,sequenceImageFormat,videoImageFormat,+ jpegQuality,codec,muted,enforceAudioTrack,proResProfile,x264Preset,pixelFormat,+ crf,+ videoBitrate,+ audioBitrate,+ audioCodec,+ everyNthFrame,+ numberOfGifLoops,+ disallowParallelEncoding,+ encodingBufferSize,+ encodingMaxRate,+ forSeamlessAacConcatenation,+ separateAudioTo,colorSpace,scale,logLevel,delayRenderTimeout,hardwareAcceleration,chromeMode,+ headless,+ disableWebSecurity,+ ignoreCertificateErrors,+ gl,+ userAgent,+ multiProcessOnLinux,+ darkMode,+ offthreadVideoCacheSizeInBytes,+ offthreadVideoThreads,+ mediaCacheSizeInBytes,+ beepOnFinish,+ repro,+ metadata,+ envVariables,inputProps,-}: {- remotionVersion: string;- locationHref: string;- compositionId: string;- renderMode: RenderMode;- renderDefaults: RenderDefaults;- durationInFrames: number;- frame: number;- startFrame: number;- endFrame: number;- stillImageFormat: string;- sequenceImageFormat: string;- videoImageFormat: string;- codec: string;- muted: boolean;- enforceAudioTrack: boolean;- proResProfile: _InternalTypes['ProResProfile'] | null;- x264Preset: string | null;- pixelFormat: string;- colorSpace: string;- scale: number;- logLevel: string;- delayRenderTimeout: number;- hardwareAcceleration: string;- chromeMode: string;- inputProps: Record<string, unknown>;-}) => {+}: ReadOnlyStudioRenderCommandInput) => {const serveUrl = normalizeServeUrlForRenderCommand({locationHref,compositionId,});- const commandType = renderMode === 'still' ? 'still' : 'render';+ const isStillRender = renderMode === 'still';+ const isSequenceRender = renderMode === 'sequence';+ const hasCodecSpecificOptions = !isSequenceRender;+ const commandType = isStillRender ? 'still' : 'render';const command = getNpmRemotionCommandPrefix(remotionVersion);const {options} = BrowserSafeApis;const flags: string[] = [];- if (scale !== renderDefaults.scale) {- addFlagWithValue(flags, options.scaleOption.cliFlag, scale);- }-- if (logLevel !== renderDefaults.logLevel) {- addFlagWithValue(flags, options.logLevelOption.cliFlag, logLevel);- }-- if (delayRenderTimeout !== renderDefaults.delayRenderTimeout) {- addFlagWithValue(- flags,- options.delayRenderTimeoutInMillisecondsOption.cliFlag,+ addValueFlagsIfChanged(flags, [+ valueFlag(options.scaleOption.cliFlag, scale, renderDefaults.scale),+ renderMediaValueFlag('logLevel', logLevel, renderDefaults.logLevel),+ renderMediaValueFlag(+ 'timeoutInMilliseconds',delayRenderTimeout,- );- }+ renderDefaults.delayRenderTimeout,+ ),+ renderMediaValueFlag('chromeMode', chromeMode, renderDefaults.chromeMode),+ valueFlag(options.glOption.cliFlag, gl, renderDefaults.openGlRenderer),+ valueFlag(+ options.userAgentOption.cliFlag,+ userAgent,+ renderDefaults.userAgent,+ ),+ renderMediaValueFlag(+ 'offthreadVideoCacheSizeInBytes',+ offthreadVideoCacheSizeInBytes,+ renderDefaults.offthreadVideoCacheSizeInBytes,+ ),+ renderMediaValueFlag(+ 'offthreadVideoThreads',+ offthreadVideoThreads,+ renderDefaults.offthreadVideoThreads,+ ),+ renderMediaValueFlag(+ 'mediaCacheSizeInBytes',+ mediaCacheSizeInBytes,+ renderDefaults.mediaCacheSizeInBytes,+ ),+ ]);- if (hardwareAcceleration !== renderDefaults.hardwareAcceleration) {- addFlagWithValue(- flags,- options.hardwareAccelerationOption.cliFlag,- hardwareAcceleration,- );+ if (headless !== renderDefaults.headless) {+ addFlagWithValue(flags, options.headlessOption.cliFlag, !headless);}- if (chromeMode !== renderDefaults.chromeMode) {- addFlagWithValue(flags, options.chromeModeOption.cliFlag, chromeMode);- }+ addTrueBooleanFlagsIfChanged(flags, [+ booleanFlag(+ options.disableWebSecurityOption.cliFlag,+ disableWebSecurity,+ renderDefaults.disableWebSecurity,+ ),+ booleanFlag(+ options.ignoreCertificateErrorsOption.cliFlag,+ ignoreCertificateErrors,+ renderDefaults.ignoreCertificateErrors,+ ),+ booleanFlag(+ options.enableMultiprocessOnLinuxOption.cliFlag,+ multiProcessOnLinux,+ renderDefaults.multiProcessOnLinux,+ ),+ booleanFlag(+ options.darkModeOption.cliFlag,+ darkMode,+ renderDefaults.darkMode,+ ),+ booleanFlag(+ options.beepOnFinishOption.cliFlag,+ beepOnFinish,+ renderDefaults.beepOnFinish,+ ),+ ]);- if (renderMode === 'still') {- if (frame !== 0) {- addFlagWithValue(flags, options.stillFrameOption.cliFlag, frame);- }-- if (stillImageFormat !== renderDefaults.stillImageFormat) {- addFlagWithValue(- flags,+ if (isStillRender) {+ addValueFlagsIfChanged(flags, [+ valueFlag(options.stillFrameOption.cliFlag, frame, 0),+ valueFlag(options.stillImageFormatOption.cliFlag,stillImageFormat,- );- }+ renderDefaults.stillImageFormat,+ ),+ valueFlag(+ options.jpegQualityOption.cliFlag,+ jpegQuality,+ renderDefaults.jpegQuality,+ ),+ ]);} else {- if (renderMode === 'sequence') {+ addValueFlagsIfChanged(flags, [+ valueFlag(+ options.concurrencyOption.cliFlag,+ concurrency,+ renderDefaults.concurrency,+ ),+ ]);++ if (isSequenceRender) {addBooleanFlag(flags, options.imageSequenceOption.cliFlag, true);if (sequenceImageFormat !== 'jpeg') {addFlagWithValue(@@ -170,16 +410,23 @@ export const makeReadOnlyStudioRenderCommand = ({sequenceImageFormat,);}- } else if (videoImageFormat !== renderDefaults.videoImageFormat) {- addFlagWithValue(- flags,- options.videoImageFormatOption.cliFlag,- videoImageFormat,- );+ } else {+ addValueFlagsIfChanged(flags, [+ valueFlag(+ options.videoImageFormatOption.cliFlag,+ videoImageFormat,+ renderDefaults.videoImageFormat,+ ),+ renderMediaValueFlag(+ 'hardwareAcceleration',+ hardwareAcceleration,+ renderDefaults.hardwareAcceleration,+ ),+ ]);}- if (codec !== renderDefaults.codec) {- addFlagWithValue(flags, options.videoCodecOption.cliFlag, codec);+ if (hasCodecSpecificOptions && codec !== renderDefaults.codec) {+ addFlagWithValue(flags, getRenderMediaFlag('codec'), codec);}if (startFrame !== 0 || endFrame !== durationInFrames - 1) {@@ -190,36 +437,107 @@ export const makeReadOnlyStudioRenderCommand = ({);}- if (muted && muted !== renderDefaults.muted) {- addBooleanFlag(flags, options.mutedOption.cliFlag, true);- }+ if (hasCodecSpecificOptions) {+ addTrueBooleanFlagsIfChanged(flags, [+ renderMediaBooleanFlag('muted', muted, renderDefaults.muted),+ booleanFlag(+ options.enforceAudioOption.cliFlag,+ enforceAudioTrack,+ renderDefaults.enforceAudioTrack,+ ),+ renderMediaBooleanFlag(+ 'forSeamlessAacConcatenation',+ forSeamlessAacConcatenation,+ renderDefaults.forSeamlessAacConcatenation,+ ),+ ]);- if (- enforceAudioTrack &&- enforceAudioTrack !== renderDefaults.enforceAudioTrack- ) {- addBooleanFlag(flags, options.enforceAudioOption.cliFlag, true);- }+ addValueFlagsIfChanged(flags, [+ valueFlag(+ options.pixelFormatOption.cliFlag,+ pixelFormat,+ renderDefaults.pixelFormat,+ ),+ renderMediaValueFlag(+ 'colorSpace',+ colorSpace,+ renderDefaults.colorSpace,+ ),+ valueFlag(+ options.proResProfileOption.cliFlag,+ proResProfile,+ renderDefaults.proResProfile,+ ),+ renderMediaValueFlag(+ 'x264Preset',+ x264Preset,+ renderDefaults.x264Preset,+ ),+ valueFlag(options.crfOption.cliFlag, crf, null),+ valueFlag(+ options.jpegQualityOption.cliFlag,+ jpegQuality,+ renderDefaults.jpegQuality,+ ),+ renderMediaValueFlag(+ 'videoBitrate',+ videoBitrate,+ renderDefaults.videoBitrate,+ ),+ renderMediaValueFlag(+ 'audioBitrate',+ audioBitrate,+ renderDefaults.audioBitrate,+ ),+ valueFlag(+ options.everyNthFrameOption.cliFlag,+ everyNthFrame,+ renderDefaults.everyNthFrame,+ ),+ renderMediaValueFlag(+ 'numberOfGifLoops',+ numberOfGifLoops,+ renderDefaults.numberOfGifLoops,+ ),+ renderMediaValueFlag(+ 'encodingBufferSize',+ encodingBufferSize,+ renderDefaults.encodingBufferSize,+ ),+ renderMediaValueFlag(+ 'encodingMaxRate',+ encodingMaxRate,+ renderDefaults.encodingMaxRate,+ ),+ renderMediaValueFlag('separateAudioTo', separateAudioTo, null),+ ]);- if (pixelFormat !== renderDefaults.pixelFormat) {- addFlagWithValue(flags, options.pixelFormatOption.cliFlag, pixelFormat);+ const defaultAudioCodec = BrowserSafeApis.defaultAudioCodecs[+ codec as keyof typeof BrowserSafeApis.defaultAudioCodecs+ ]?.compressed as string | undefined;+ if (audioCodec !== defaultAudioCodec) {+ addFlagWithValue(flags, getRenderMediaFlag('audioCodec'), audioCodec);+ }}- if (colorSpace !== renderDefaults.colorSpace) {- addFlagWithValue(flags, options.colorSpaceOption.cliFlag, colorSpace);- }+ addTrueBooleanFlagsIfChanged(flags, [+ renderMediaBooleanFlag(+ 'disallowParallelEncoding',+ disallowParallelEncoding,+ false,+ ),+ renderMediaBooleanFlag('repro', repro, renderDefaults.repro),+ ]);+ }- if (proResProfile && proResProfile !== renderDefaults.proResProfile) {+ if (metadata) {+ for (const [key, value] of Object.entries(metadata)) {addFlagWithValue(flags,- options.proResProfileOption.cliFlag,- proResProfile,+ options.metadataOption.cliFlag,+ `${key}=${value}`,);}-- if (x264Preset && x264Preset !== renderDefaults.x264Preset) {- addFlagWithValue(flags, options.x264Option.cliFlag, x264Preset);- }}addFlagWithValue(@@ -228,11 +546,22 @@ export const makeReadOnlyStudioRenderCommand = ({JSON.stringify(inputProps),);- return [+ const envArgs = Object.entries(envVariables)+ .sort(([a], [b]) => a.localeCompare(b))+ .map(([key, value]) => shellQuote(`${key}=${value}`));++ const renderCommand = [command,commandType,shellQuote(serveUrl),shellQuote(compositionId),+ shellQuote(trimDefaultOutPrefix(outName)),...flags,].join(' ');++ if (envArgs.length === 0) {+ return renderCommand;+ }++ return ['env', ...envArgs, renderCommand].join(' ');};diff --git a/packages/studio/src/test/make-render-command.test.ts b/packages/studio/src/test/make-render-command.test.tsindex 9ebd894f23..5c388ec186 100644--- a/packages/studio/src/test/make-render-command.test.ts+++ b/packages/studio/src/test/make-render-command.test.ts@@ -52,6 +52,66 @@ const getDefaults = (): RenderDefaults => {};};+const getBaseInput = (): Parameters<+ typeof makeReadOnlyStudioRenderCommand+>[0] => {+ return {+ remotionVersion: '4.0.431',+ locationHref: 'https://example.com/base',+ compositionId: 'Comp',+ outName: 'out/video.mp4',+ renderMode: 'video',+ renderDefaults: getDefaults(),+ durationInFrames: 120,+ concurrency: 4,+ frame: 0,+ startFrame: 0,+ endFrame: 119,+ stillImageFormat: 'png',+ sequenceImageFormat: 'png',+ videoImageFormat: 'jpeg',+ jpegQuality: 80,+ codec: 'h264',+ muted: false,+ enforceAudioTrack: false,+ proResProfile: null,+ x264Preset: 'medium',+ pixelFormat: 'yuv420p',+ crf: null,+ videoBitrate: null,+ audioBitrate: null,+ audioCodec: 'aac',+ everyNthFrame: 1,+ numberOfGifLoops: null,+ disallowParallelEncoding: false,+ encodingBufferSize: null,+ encodingMaxRate: null,+ forSeamlessAacConcatenation: false,+ separateAudioTo: null,+ colorSpace: 'default',+ scale: 1,+ logLevel: 'info',+ delayRenderTimeout: 30000,+ hardwareAcceleration: 'if-possible',+ chromeMode: 'headless-shell',+ headless: true,+ disableWebSecurity: false,+ ignoreCertificateErrors: false,+ gl: null,+ userAgent: null,+ multiProcessOnLinux: false,+ darkMode: false,+ offthreadVideoCacheSizeInBytes: null,+ offthreadVideoThreads: null,+ mediaCacheSizeInBytes: null,+ beepOnFinish: false,+ repro: false,+ metadata: null,+ envVariables: {},+ inputProps: {},+ };+};+test('Should map to npm-based command prefix', () => {expect(getNpmRemotionCommandPrefix('4.0.431')).toBe('npx -p @remotion/[email protected] remotion',@@ -76,80 +136,112 @@ test('Should normalize serve URL by stripping selected composition', () => {test('Should generate concise read-only render command and omit concurrency', () => {const command = makeReadOnlyStudioRenderCommand({- remotionVersion: '4.0.431',+ ...getBaseInput(),locationHref: 'https://example.com/dynamic-length',compositionId: 'dynamic-length',- renderMode: 'video',- renderDefaults: getDefaults(),+ outName: 'out/video.mp4',durationInFrames: 200,- frame: 0,startFrame: 10,endFrame: 80,- stillImageFormat: 'png',- sequenceImageFormat: 'png',- videoImageFormat: 'jpeg',- codec: 'h264',muted: true,- enforceAudioTrack: false,- proResProfile: null,- x264Preset: 'medium',- pixelFormat: 'yuv420p',- colorSpace: 'default',- scale: 1,- logLevel: 'info',- delayRenderTimeout: 30000,- hardwareAcceleration: 'if-possible',- chromeMode: 'headless-shell',+ crf: 19,inputProps: {title: "It's me",},});expect(command).toContain(- "npx -p @remotion/[email protected] remotion render 'https://example.com' 'dynamic-length'",+ "npx -p @remotion/[email protected] remotion render 'https://example.com' 'dynamic-length' 'video.mp4'",);expect(command).toContain("--frames='10-80'");expect(command).toContain('--muted');+ expect(command).toContain("--crf='19'");expect(command).toContain("It'\\''s me");expect(command).not.toContain('--concurrency=');});test('Should generate still command and omit default flags', () => {const command = makeReadOnlyStudioRenderCommand({- remotionVersion: '4.0.431',+ ...getBaseInput(),locationHref: 'https://example.com/still',compositionId: 'StillComp',+ outName: 'out/still.png',renderMode: 'still',- renderDefaults: getDefaults(),- durationInFrames: 120,frame: 12,- startFrame: 0,- endFrame: 119,- stillImageFormat: 'png',- sequenceImageFormat: 'png',- videoImageFormat: 'jpeg',- codec: 'h264',- muted: false,- enforceAudioTrack: false,- proResProfile: null,- x264Preset: 'medium',- pixelFormat: 'yuv420p',- colorSpace: 'default',- scale: 1,- logLevel: 'info',- delayRenderTimeout: 30000,- hardwareAcceleration: 'if-possible',- chromeMode: 'headless-shell',inputProps: {message: 'Hello',},});expect(command).toContain(- "npx -p @remotion/[email protected] remotion still 'https://example.com/still' 'StillComp'",+ "npx -p @remotion/[email protected] remotion still 'https://example.com/still' 'StillComp' 'still.png'",);expect(command).toContain("--frame='12'");expect(command).not.toContain("--image-format='png'");expect(command).not.toContain('--codec=');expect(command).not.toContain('--frames=');});++test('Should include custom bitrate and audio codec flags', () => {+ const command = makeReadOnlyStudioRenderCommand({+ ...getBaseInput(),+ locationHref: 'https://example.com/my-comp',+ compositionId: 'my-comp',+ outName: 'out/custom.mp4',+ videoBitrate: '6M',+ audioBitrate: '256K',+ audioCodec: 'mp3',+ });++ expect(command).toContain("--video-bitrate='6M'");+ expect(command).toContain("--audio-bitrate='256K'");+ expect(command).toContain("--audio-codec='mp3'");+});++test('Should include advanced flags and env variables', () => {+ const command = makeReadOnlyStudioRenderCommand({+ ...getBaseInput(),+ outName: 'out/advanced.mp4',+ concurrency: 6,+ disallowParallelEncoding: true,+ encodingBufferSize: '10000k',+ encodingMaxRate: '5000k',+ forSeamlessAacConcatenation: true,+ separateAudioTo: 'out/advanced.aac',+ disableWebSecurity: true,+ ignoreCertificateErrors: true,+ headless: false,+ gl: 'vulkan',+ userAgent: 'Mozilla/5.0 (Remotion)',+ multiProcessOnLinux: true,+ darkMode: true,+ offthreadVideoCacheSizeInBytes: 536870912,+ offthreadVideoThreads: 2,+ mediaCacheSizeInBytes: 1000000000,+ beepOnFinish: true,+ repro: true,+ metadata: {artist: 'Remotion'},+ envVariables: {FOO: 'bar'},+ });++ expect(command).toContain("env 'FOO=bar'");+ expect(command).toContain("--concurrency='6'");+ expect(command).toContain('--disallow-parallel-encoding');+ expect(command).toContain("--buffer-size='10000k'");+ expect(command).toContain("--max-rate='5000k'");+ expect(command).toContain('--for-seamless-aac-concatenation');+ expect(command).toContain("--separate-audio-to='out/advanced.aac'");+ expect(command).toContain('--disable-web-security');+ expect(command).toContain('--ignore-certificate-errors');+ expect(command).toContain('--disable-headless');+ expect(command).toContain("--gl='vulkan'");+ expect(command).toContain("--user-agent='Mozilla/5.0 (Remotion)'");+ expect(command).toContain('--enable-multiprocess-on-linux');+ expect(command).toContain('--dark-mode');+ expect(command).toContain("--offthreadvideo-cache-size-in-bytes='536870912'");+ expect(command).toContain("--offthreadvideo-video-threads='2'");+ expect(command).toContain("--media-cache-size-in-bytes='1000000000'");+ expect(command).toContain('--beep-on-finish');+ expect(command).toContain('--repro');+ expect(command).toContain("--metadata='artist=Remotion'");+});