π₯ Make videos programmatically with React
`@remotion/vercel`: Switch to internalRenderMedia/internalRenderStill
Jonny Burgerf54a608e2a69
diff --git a/packages/docs/docs/vercel/render-still-on-vercel.mdx b/packages/docs/docs/vercel/render-still-on-vercel.mdxindex 9e86515d33..6fcc9c71bb 100644--- a/packages/docs/docs/vercel/render-still-on-vercel.mdx+++ b/packages/docs/docs/vercel/render-still-on-vercel.mdx@@ -6,7 +6,7 @@ crumb: '@remotion/vercel'# renderStillOnVercel()<AvailableFrom v="4.0.425" />-Renders a still image inside a Vercel Sandbox. Writes a render script to the sandbox, executes it, and returns the output file path.+Renders a still image inside a Vercel Sandbox using [`RenderInternals.internalRenderStill()`](/docs/renderer/render-still). Writes a render script to the sandbox, executes it, and returns the output file path.The rendered file stays inside the sandbox. Use [`uploadToVercelBlob()`](/docs/vercel/upload-to-vercel-blob) to upload it to Vercel Blob.@@ -44,15 +44,75 @@ Props to pass to the composition.### `imageFormat?`-The output image format. Default: `"png"`. Can be `"png"`, `"jpeg"`, or `"webp"`.+The output image format. `"png"`, `"jpeg"`, `"pdf"`, or `"webp"`. Default: `"png"`.### `outputFile?`The output file path inside the sandbox. Default: `"/tmp/still.png"`.+### `frame?`++The frame number to render. Default: `0`.++### `jpegQuality?`++JPEG quality (0β100). Only applicable when `imageFormat` is `"jpeg"`. Default: `80`.++### `envVariables?`++Environment variables to set during rendering. Default: `{}`.++### `overwrite?`++Whether to overwrite existing output files. Default: `true`.++### `browserExecutable?`++Custom path to a Chrome executable. Default: `null` (use installed browser).++### `chromiumOptions?`++Options for the headless Chrome instance. See [`renderStill() β chromiumOptions`](/docs/renderer/render-still#chromiumoptions). Default: `{}`.++### `scale?`++Scaling factor for the output. Default: `1`.++### `logLevel?`++Log level for the render process. `"trace"`, `"verbose"`, `"info"`, `"warn"`, or `"error"`. Default: `"info"`.++### `timeoutInMilliseconds?`++Timeout for delayRender() calls in milliseconds. Default: `30000`.++### `chromeMode?`++Chrome mode. `"headless-shell"` or `"chrome-for-testing"`. Default: `"headless-shell"`.++### `offthreadVideoCacheSizeInBytes?`++Cache size for `<OffthreadVideo>` in bytes. Default: `null`.++### `mediaCacheSizeInBytes?`++Cache size for media assets in bytes. Default: `null`.++### `offthreadVideoThreads?`++Number of threads for `<OffthreadVideo>` decoding. Default: `null`.++### `binariesDirectory?`++Custom directory for FFmpeg binaries. Default: `null`.++### `licenseKey?`++Remotion license key. Default: `null`.+### `onProgress?`-A callback that receives render progress updates. See [`renderVideoOnVercel()`](/docs/vercel/render-video-on-vercel) for the type definition.+A callback that receives render progress updates. See [`renderVideoOnVercel()`](/docs/vercel/render-video-on-vercel#onprogress) for the type definition.### `bundleDir?`diff --git a/packages/docs/docs/vercel/render-video-on-vercel.mdx b/packages/docs/docs/vercel/render-video-on-vercel.mdxindex c0810f218c..ad6e69d0a1 100644--- a/packages/docs/docs/vercel/render-video-on-vercel.mdx+++ b/packages/docs/docs/vercel/render-video-on-vercel.mdx@@ -6,7 +6,7 @@ crumb: '@remotion/vercel'# renderVideoOnVercel()<AvailableFrom v="4.0.425" />-Renders a video inside a Vercel Sandbox. Writes a render script to the sandbox, executes it, and returns the output file path.+Renders a video inside a Vercel Sandbox using [`RenderInternals.internalRenderMedia()`](/docs/renderer/render-media). Writes a render script to the sandbox, executes it, and returns the output file path.The rendered file stays inside the sandbox. Use [`uploadToVercelBlob()`](/docs/vercel/upload-to-vercel-blob) to upload it to Vercel Blob.@@ -54,12 +54,178 @@ The video codec to use. Default: `"h264"`.The output file path inside the sandbox. Default: `"/tmp/video.mp4"`.+### `crf?`++The Constant Rate Factor, controlling quality. See [`renderMedia() β crf`](/docs/renderer/render-media#crf). Default: `null` (codec default).++### `imageFormat?`++The image format for intermediate frames. `"png"`, `"jpeg"`, or `"none"`. Default: `null` (codec default).++### `pixelFormat?`++The pixel format for the output video. Default: `null` (codec default).++### `envVariables?`++Environment variables to set during rendering. Default: `{}`.++### `frameRange?`++A specific frame range to render. Can be a single frame number, a `[start, end]` tuple, or `[start, null]` for open-ended. Default: `null` (render all frames).++### `everyNthFrame?`++Render only every nth frame. Default: `1`.++### `overwrite?`++Whether to overwrite existing output files. Default: `true`.++### `proResProfile?`++The ProRes profile to use when `codec` is `"prores"`. One of `"4444-xq"`, `"4444"`, `"hq"`, `"standard"`, `"light"`, `"proxy"`.++### `chromiumOptions?`++Options for the headless Chrome instance. See [`renderMedia() β chromiumOptions`](/docs/renderer/render-media#chromiumoptions). Default: `{}`.++### `scale?`++Scaling factor for the output. Default: `1`.++### `browserExecutable?`++Custom path to a Chrome executable. Default: `null` (use installed browser).++### `preferLossless?`++Prefer lossless audio encoding when possible. Default: `false`.++### `enforceAudioTrack?`++Enforce an audio track even if the video has no audio. Default: `false`.++### `disallowParallelEncoding?`++Disable parallel encoding. Default: `false`.++### `concurrency?`++Number of frames to render concurrently. Default: `null` (auto).++### `metadata?`++Key-value metadata to embed in the output file. Default: `null`.++### `logLevel?`++Log level for the render process. `"trace"`, `"verbose"`, `"info"`, `"warn"`, or `"error"`. Default: `"info"`.++### `timeoutInMilliseconds?`++Timeout for delayRender() calls in milliseconds. Default: `30000`.++### `videoBitrate?`++Target video bitrate, e.g. `"1000k"` or `"10M"`. Default: `null`.++### `audioBitrate?`++Target audio bitrate, e.g. `"128k"`. Default: `null`.++### `audioCodec?`++The audio codec. `"pcm-16"`, `"aac"`, `"mp3"`, or `"opus"`. Default: `null` (derived from video codec).++### `encodingMaxRate?`++Maximum encoding bitrate for VBR encoding. Default: `null`.++### `encodingBufferSize?`++Encoding buffer size for VBR encoding. Default: `null`.++### `muted?`++Render without audio. Default: `false`.++### `numberOfGifLoops?`++Number of loops for GIF output. Default: `null`.++### `x264Preset?`++The x264 preset when using H.264 codec. Default: `null`.++### `colorSpace?`++The color space. `"default"`, `"bt601"`, `"bt709"`, or `"bt2020-ncl"`. Default: `"default"`.++### `jpegQuality?`++JPEG quality for intermediate frames (0β100). Default: `80`.++### `forSeamlessAacConcatenation?`++Optimize AAC audio for seamless concatenation. Default: `false`.++### `separateAudioTo?`++Write the audio track to a separate file. Default: `null`.++### `hardwareAcceleration?`++Hardware acceleration mode. `"disable"`, `"if-possible"`, or `"required"`. Default: `"disable"`.++### `chromeMode?`++Chrome mode. `"headless-shell"` or `"chrome-for-testing"`. Default: `"headless-shell"`.++### `offthreadVideoCacheSizeInBytes?`++Cache size for `<OffthreadVideo>` in bytes. Default: `null`.++### `mediaCacheSizeInBytes?`++Cache size for media assets in bytes. Default: `null`.++### `offthreadVideoThreads?`++Number of threads for `<OffthreadVideo>` decoding. Default: `null`.++### `repro?`++Enable repro mode for debugging. Default: `false`.++### `binariesDirectory?`++Custom directory for FFmpeg binaries. Default: `null`.++### `licenseKey?`++Remotion license key. Default: `null`.+### `onProgress?`A callback that receives render progress updates.```ts-type RenderOnVercelProgress = {type: 'opening-browser'} | {type: 'selecting-composition'} | {type: 'render-progress'; progress: number} | {type: 'uploading'} | {type: 'done'; url: string; size: number};+type RenderOnVercelProgress =+ | {type: 'opening-browser'}+ | {type: 'selecting-composition'}+ | {+ type: 'render-progress';+ renderedFrames: number;+ encodedFrames: number;+ encodedDoneIn: number | null;+ renderedDoneIn: number | null;+ renderEstimatedTime: number;+ progress: number;+ stitchStage: 'encoding' | 'muxing';+ }+ | {type: 'uploading'}+ | {type: 'done'; url: string; size: number};```### `bundleDir?`diff --git a/packages/docs/docs/vercel/types.mdx b/packages/docs/docs/vercel/types.mdxindex f79a504091..8379afcddd 100644--- a/packages/docs/docs/vercel/types.mdx+++ b/packages/docs/docs/vercel/types.mdx@@ -37,6 +37,6 @@ import type {RenderOnVercelProgress} from '@remotion/vercel';- `{type: 'opening-browser'}`: The browser is being opened- `{type: 'selecting-composition'}`: The composition is being selected-- `{type: 'render-progress', progress: number}`: Rendering is in progress (`0` to `1`)+- `{type: 'render-progress', ...}`: Rendering is in progress. Includes `progress` (`0` to `1`), `renderedFrames`, `encodedFrames`, `encodedDoneIn`, `renderedDoneIn`, `renderEstimatedTime`, and `stitchStage` (`'encoding'` or `'muxing'`)- `{type: 'uploading'}`: The rendered file is being uploaded- `{type: 'done', url: string, size: number}`: The render is completediff --git a/packages/vercel/src/index.ts b/packages/vercel/src/index.tsindex 4e837ff51b..9ef1a5a6f7 100644--- a/packages/vercel/src/index.ts+++ b/packages/vercel/src/index.ts@@ -4,8 +4,24 @@ export {renderVideoOnVercel} from './render-video-on-vercel';export {restoreSnapshot} from './restore-snapshot';export {saveSnapshot} from './save-snapshot';export type {+ AudioCodec,+ Bitrate,+ ChromeMode,+ ChromiumOptions,+ Codec,+ ColorSpace,CreateSandboxOnProgress,+ FrameRange,+ HardwareAccelerationOption,+ LogLevel,+ OpenGlRenderer,+ PixelFormat,+ ProResProfile,RenderOnVercelProgress,+ StillImageFormat,+ StitchingState,VercelSandbox,+ VideoImageFormat,+ X264Preset,} from './types';export {uploadToVercelBlob} from './upload-to-vercel-blob';diff --git a/packages/vercel/src/internals/render-still-script.ts b/packages/vercel/src/internals/render-still-script.tsindex 1f770426f7..e7c34d5f13 100644--- a/packages/vercel/src/internals/render-still-script.ts+++ b/packages/vercel/src/internals/render-still-script.ts@@ -1,33 +1,142 @@// Generated by bundle.ts - do not edit manually-export const script = `import {openBrowser, renderStill, selectComposition} from '@remotion/renderer';+export const script = `import {RenderInternals} from '@remotion/renderer';import {statSync} from 'fs';+import {NoReactInternals} from 'remotion/no-react';-const config = JSON.parse(process.argv[2]);+type InternalStillOptions = Parameters<+ typeof RenderInternals.internalRenderStill+>[0];++type RenderStillConfig = {+ compositionId: string;+ inputProps: Record<string, unknown>;+ output: InternalStillOptions['output'];+ serveUrl: InternalStillOptions['serveUrl'];+ frame: InternalStillOptions['frame'];+ imageFormat: InternalStillOptions['imageFormat'];+ jpegQuality: InternalStillOptions['jpegQuality'];+ envVariables: InternalStillOptions['envVariables'];+ overwrite: InternalStillOptions['overwrite'];+ browserExecutable: InternalStillOptions['browserExecutable'];+ chromiumOptions: InternalStillOptions['chromiumOptions'];+ scale: InternalStillOptions['scale'];+ logLevel: InternalStillOptions['logLevel'];+ timeoutInMilliseconds: InternalStillOptions['timeoutInMilliseconds'];+ binariesDirectory: InternalStillOptions['binariesDirectory'];+ chromeMode: InternalStillOptions['chromeMode'];+ offthreadVideoCacheSizeInBytes: InternalStillOptions['offthreadVideoCacheSizeInBytes'];+ mediaCacheSizeInBytes: InternalStillOptions['mediaCacheSizeInBytes'];+ offthreadVideoThreads: InternalStillOptions['offthreadVideoThreads'];+ licenseKey: InternalStillOptions['licenseKey'];+};++const config: RenderStillConfig = JSON.parse(process.argv[2]);++const noop = () => undefined;try {+ const serializedInputProps = NoReactInternals.serializeJSONWithSpecialTypes({+ data: config.inputProps,+ indent: undefined,+ staticBase: null,+ }).serializedString;+console.log(JSON.stringify({type: 'opening-browser'}));- const browser = await openBrowser('chrome');- console.log(JSON.stringify({type: 'selecting-composition'}));- const composition = await selectComposition({- serveUrl: config.serveUrl,- id: config.compositionId,- inputProps: config.inputProps,- puppeteerInstance: browser,++ const browser = await RenderInternals.internalOpenBrowser({+ browser: 'chrome',+ browserExecutable: config.browserExecutable,+ chromiumOptions: config.chromiumOptions,+ forceDeviceScaleFactor: undefined,+ viewport: null,+ indent: false,+ logLevel: config.logLevel,+ onBrowserDownload: () => ({+ version: null,+ onProgress: noop,+ }),+ chromeMode: config.chromeMode,});- await renderStill({+ console.log(JSON.stringify({type: 'selecting-composition'}));++ const {metadata: composition} =+ await RenderInternals.internalSelectComposition({+ serializedInputPropsWithCustomSchema: serializedInputProps,+ envVariables: config.envVariables,+ puppeteerInstance: browser,+ onBrowserLog: null,+ browserExecutable: config.browserExecutable,+ chromiumOptions: config.chromiumOptions,+ port: null,+ indent: false,+ server: undefined,+ serveUrl: config.serveUrl,+ id: config.compositionId,+ onServeUrlVisited: noop,+ logLevel: config.logLevel,+ timeoutInMilliseconds: config.timeoutInMilliseconds,+ binariesDirectory: config.binariesDirectory,+ onBrowserDownload: () => ({+ version: null,+ onProgress: noop,+ }),+ chromeMode: config.chromeMode,+ mediaCacheSizeInBytes: config.mediaCacheSizeInBytes,+ offthreadVideoCacheSizeInBytes: config.offthreadVideoCacheSizeInBytes,+ offthreadVideoThreads: config.offthreadVideoThreads,+ });++ const serializedResolvedProps =+ NoReactInternals.serializeJSONWithSpecialTypes({+ data: composition.props,+ indent: undefined,+ staticBase: null,+ }).serializedString;++ await RenderInternals.internalRenderStill({+ output: config.output,composition,+ serializedInputPropsWithCustomSchema: serializedInputProps,+ serializedResolvedPropsWithCustomSchema: serializedResolvedProps,serveUrl: config.serveUrl,+ frame: config.frame,imageFormat: config.imageFormat,- output: config.outputFile,- inputProps: config.inputProps,+ jpegQuality: config.jpegQuality,+ envVariables: config.envVariables,+ overwrite: config.overwrite,+ browserExecutable: config.browserExecutable,+ chromiumOptions: config.chromiumOptions,+ scale: config.scale,+ logLevel: config.logLevel,+ timeoutInMilliseconds: config.timeoutInMilliseconds,+ binariesDirectory: config.binariesDirectory,+ chromeMode: config.chromeMode,+ offthreadVideoCacheSizeInBytes: config.offthreadVideoCacheSizeInBytes,+ mediaCacheSizeInBytes: config.mediaCacheSizeInBytes,+ offthreadVideoThreads: config.offthreadVideoThreads,+ licenseKey: config.licenseKey,+ // Non-serializable fields with defaultspuppeteerInstance: browser,+ onBrowserLog: null,+ onDownload: null,+ cancelSignal: null,+ indent: false,+ server: undefined,+ port: null,+ onArtifact: null,+ onLog: RenderInternals.defaultOnLog,+ isProduction: true,+ onBrowserDownload: () => ({+ version: null,+ onProgress: noop,+ }),});console.log(JSON.stringify({type: 'render-complete'}));await browser.close({silent: false});- const size = statSync(config.outputFile).size;+ const {size} = statSync(config.output ?? '/tmp/still.png');console.log(JSON.stringify({type: 'done', size}));} catch (err) {console.error((err as Error).message);diff --git a/packages/vercel/src/internals/render-video-script.ts b/packages/vercel/src/internals/render-video-script.tsindex 5ea1aa29a2..73262d2079 100644--- a/packages/vercel/src/internals/render-video-script.ts+++ b/packages/vercel/src/internals/render-video-script.ts@@ -1,36 +1,205 @@// Generated by bundle.ts - do not edit manually-export const script = `import {openBrowser, renderMedia, selectComposition} from '@remotion/renderer';+export const script = `import type {InternalRenderMediaOptions} from '@remotion/renderer';+import {RenderInternals} from '@remotion/renderer';import {statSync} from 'fs';+import {NoReactInternals} from 'remotion/no-react';-const config = JSON.parse(process.argv[2]);+type RenderVideoConfig = {+ compositionId: string;+ inputProps: Record<string, unknown>;+ outputLocation: InternalRenderMediaOptions['outputLocation'];+ serveUrl: InternalRenderMediaOptions['serveUrl'];+ crf: InternalRenderMediaOptions['crf'];+ imageFormat: InternalRenderMediaOptions['imageFormat'];+ pixelFormat: InternalRenderMediaOptions['pixelFormat'];+ envVariables: InternalRenderMediaOptions['envVariables'];+ frameRange: InternalRenderMediaOptions['frameRange'];+ everyNthFrame: InternalRenderMediaOptions['everyNthFrame'];+ overwrite: InternalRenderMediaOptions['overwrite'];+ proResProfile: NonNullable<+ InternalRenderMediaOptions['proResProfile']+ > | null;+ chromiumOptions: InternalRenderMediaOptions['chromiumOptions'];+ scale: InternalRenderMediaOptions['scale'];+ browserExecutable: InternalRenderMediaOptions['browserExecutable'];+ preferLossless: InternalRenderMediaOptions['preferLossless'];+ enforceAudioTrack: InternalRenderMediaOptions['enforceAudioTrack'];+ disallowParallelEncoding: InternalRenderMediaOptions['disallowParallelEncoding'];+ concurrency: InternalRenderMediaOptions['concurrency'];+ binariesDirectory: InternalRenderMediaOptions['binariesDirectory'];+ metadata: InternalRenderMediaOptions['metadata'];+ licenseKey: InternalRenderMediaOptions['licenseKey'];+ codec: InternalRenderMediaOptions['codec'];+ videoBitrate: InternalRenderMediaOptions['videoBitrate'];+ audioBitrate: InternalRenderMediaOptions['audioBitrate'];+ encodingMaxRate: InternalRenderMediaOptions['encodingMaxRate'];+ encodingBufferSize: InternalRenderMediaOptions['encodingBufferSize'];+ muted: InternalRenderMediaOptions['muted'];+ numberOfGifLoops: InternalRenderMediaOptions['numberOfGifLoops'];+ x264Preset: InternalRenderMediaOptions['x264Preset'];+ colorSpace: InternalRenderMediaOptions['colorSpace'];+ jpegQuality: InternalRenderMediaOptions['jpegQuality'];+ audioCodec: InternalRenderMediaOptions['audioCodec'];+ logLevel: InternalRenderMediaOptions['logLevel'];+ timeoutInMilliseconds: InternalRenderMediaOptions['timeoutInMilliseconds'];+ forSeamlessAacConcatenation: InternalRenderMediaOptions['forSeamlessAacConcatenation'];+ separateAudioTo: InternalRenderMediaOptions['separateAudioTo'];+ hardwareAcceleration: InternalRenderMediaOptions['hardwareAcceleration'];+ chromeMode: InternalRenderMediaOptions['chromeMode'];+ offthreadVideoCacheSizeInBytes: InternalRenderMediaOptions['offthreadVideoCacheSizeInBytes'];+ mediaCacheSizeInBytes: InternalRenderMediaOptions['mediaCacheSizeInBytes'];+ offthreadVideoThreads: InternalRenderMediaOptions['offthreadVideoThreads'];+ repro: InternalRenderMediaOptions['repro'];+};++const config: RenderVideoConfig = JSON.parse(process.argv[2]);++const noop = () => undefined;try {+ const serializedInputProps = NoReactInternals.serializeJSONWithSpecialTypes({+ data: config.inputProps,+ indent: undefined,+ staticBase: null,+ }).serializedString;+console.log(JSON.stringify({type: 'opening-browser'}));- const browser = await openBrowser('chrome');- console.log(JSON.stringify({type: 'selecting-composition'}));- const composition = await selectComposition({- serveUrl: config.serveUrl,- id: config.compositionId,- inputProps: config.inputProps,- puppeteerInstance: browser,++ const browser = await RenderInternals.internalOpenBrowser({+ browser: 'chrome',+ browserExecutable: config.browserExecutable,+ chromiumOptions: config.chromiumOptions,+ forceDeviceScaleFactor: undefined,+ viewport: null,+ indent: false,+ logLevel: config.logLevel,+ onBrowserDownload: () => ({+ version: null,+ onProgress: noop,+ }),+ chromeMode: config.chromeMode,});- await renderMedia({+ console.log(JSON.stringify({type: 'selecting-composition'}));++ const {metadata: composition} =+ await RenderInternals.internalSelectComposition({+ serializedInputPropsWithCustomSchema: serializedInputProps,+ envVariables: config.envVariables,+ puppeteerInstance: browser,+ onBrowserLog: null,+ browserExecutable: config.browserExecutable,+ chromiumOptions: config.chromiumOptions,+ port: null,+ indent: false,+ server: undefined,+ serveUrl: config.serveUrl,+ id: config.compositionId,+ onServeUrlVisited: noop,+ logLevel: config.logLevel,+ timeoutInMilliseconds: config.timeoutInMilliseconds,+ binariesDirectory: config.binariesDirectory,+ onBrowserDownload: () => ({+ version: null,+ onProgress: noop,+ }),+ chromeMode: config.chromeMode,+ mediaCacheSizeInBytes: config.mediaCacheSizeInBytes,+ offthreadVideoCacheSizeInBytes: config.offthreadVideoCacheSizeInBytes,+ offthreadVideoThreads: config.offthreadVideoThreads,+ });++ const serializedResolvedProps =+ NoReactInternals.serializeJSONWithSpecialTypes({+ data: composition.props,+ indent: undefined,+ staticBase: null,+ }).serializedString;++ await RenderInternals.internalRenderMedia({+ outputLocation: config.outputLocation,composition,+ serializedInputPropsWithCustomSchema: serializedInputProps,+ serializedResolvedPropsWithCustomSchema: serializedResolvedProps,serveUrl: config.serveUrl,codec: config.codec,- outputLocation: config.outputFile,- inputProps: config.inputProps,- onProgress: ({progress}) => {- console.log(JSON.stringify({type: 'progress', progress}));- },+ crf: config.crf,+ imageFormat: config.imageFormat,+ pixelFormat: config.pixelFormat,+ envVariables: config.envVariables,+ frameRange: config.frameRange,+ everyNthFrame: config.everyNthFrame,+ overwrite: config.overwrite,+ proResProfile: config.proResProfile ?? undefined,+ chromiumOptions: config.chromiumOptions,+ scale: config.scale,+ browserExecutable: config.browserExecutable,+ preferLossless: config.preferLossless,+ enforceAudioTrack: config.enforceAudioTrack,+ disallowParallelEncoding: config.disallowParallelEncoding,+ concurrency: config.concurrency,+ binariesDirectory: config.binariesDirectory,+ metadata: config.metadata,+ licenseKey: config.licenseKey,+ videoBitrate: config.videoBitrate,+ audioBitrate: config.audioBitrate,+ encodingMaxRate: config.encodingMaxRate,+ encodingBufferSize: config.encodingBufferSize,+ muted: config.muted,+ numberOfGifLoops: config.numberOfGifLoops,+ x264Preset: config.x264Preset,+ colorSpace: config.colorSpace,+ jpegQuality: config.jpegQuality,+ audioCodec: config.audioCodec,+ logLevel: config.logLevel,+ timeoutInMilliseconds: config.timeoutInMilliseconds,+ forSeamlessAacConcatenation: config.forSeamlessAacConcatenation,+ separateAudioTo: config.separateAudioTo,+ hardwareAcceleration: config.hardwareAcceleration,+ chromeMode: config.chromeMode,+ offthreadVideoCacheSizeInBytes: config.offthreadVideoCacheSizeInBytes,+ mediaCacheSizeInBytes: config.mediaCacheSizeInBytes,+ offthreadVideoThreads: config.offthreadVideoThreads,+ repro: config.repro,+ // Non-serializable fields with defaultspuppeteerInstance: browser,+ onProgress: (progress) => {+ console.log(+ JSON.stringify({+ type: 'progress',+ renderedFrames: progress.renderedFrames,+ encodedFrames: progress.encodedFrames,+ encodedDoneIn: progress.encodedDoneIn,+ renderedDoneIn: progress.renderedDoneIn,+ renderEstimatedTime: progress.renderEstimatedTime,+ progress: progress.progress,+ stitchStage: progress.stitchStage,+ }),+ );+ },+ onDownload: () => undefined,+ onBrowserLog: null,+ onStart: noop,+ port: null,+ cancelSignal: undefined,+ onCtrlCExit: noop,+ indent: false,+ server: undefined,+ ffmpegOverride: undefined,+ compositionStart: 0,+ onArtifact: null,+ onLog: RenderInternals.defaultOnLog,+ isProduction: true,+ onBrowserDownload: () => ({+ version: null,+ onProgress: noop,+ }),});console.log(JSON.stringify({type: 'render-complete'}));await browser.close({silent: false});- const size = statSync(config.outputFile).size;+ const {size} = statSync(config.outputLocation ?? '/tmp/video.mp4');console.log(JSON.stringify({type: 'done', size}));} catch (err) {console.error((err as Error).message);diff --git a/packages/vercel/src/render-still-on-vercel.ts b/packages/vercel/src/render-still-on-vercel.tsindex c912bc84e7..edd02590a3 100644--- a/packages/vercel/src/render-still-on-vercel.ts+++ b/packages/vercel/src/render-still-on-vercel.ts@@ -1,41 +1,92 @@import type {Sandbox} from '@vercel/sandbox';import {script as renderStillScript} from './internals/render-still-script';-import type {RenderOnVercelProgress} from './types';+import type {+ ChromeMode,+ ChromiumOptions,+ LogLevel,+ RenderOnVercelProgress,+ StillImageFormat,+} from './types';export async function renderStillOnVercel({sandbox,compositionId,inputProps,- imageFormat = 'png',- outputFile = '/tmp/still.png',onProgress,bundleDir = '.remotion',+ outputFile = '/tmp/still.png',+ frame = 0,+ imageFormat = 'png',+ jpegQuality = 80,+ envVariables = {},+ overwrite = true,+ browserExecutable,+ chromiumOptions = {},+ scale = 1,+ logLevel = 'info',+ timeoutInMilliseconds = 30000,+ binariesDirectory,+ chromeMode = 'headless-shell',+ offthreadVideoCacheSizeInBytes,+ mediaCacheSizeInBytes,+ offthreadVideoThreads,+ licenseKey,}: {sandbox: Sandbox;compositionId: string;inputProps: Record<string, unknown>;- imageFormat?: 'png' | 'jpeg' | 'webp';- outputFile?: string;onProgress?: (progress: RenderOnVercelProgress) => void;bundleDir?: string;+ outputFile?: string;+ frame?: number;+ imageFormat?: StillImageFormat;+ jpegQuality?: number;+ envVariables?: Record<string, string>;+ overwrite?: boolean;+ browserExecutable?: string | null;+ chromiumOptions?: ChromiumOptions;+ scale?: number;+ logLevel?: LogLevel;+ timeoutInMilliseconds?: number;+ binariesDirectory?: string | null;+ chromeMode?: ChromeMode;+ offthreadVideoCacheSizeInBytes?: number | null;+ mediaCacheSizeInBytes?: number | null;+ offthreadVideoThreads?: number | null;+ licenseKey?: string | null;}): Promise<{file: string}> {const serveUrl = `/vercel/sandbox/${bundleDir}`;- await sandbox.writeFiles([- {- path: 'render-still.ts',- content: Buffer.from(renderStillScript),- },- ]);-const renderConfig = {serveUrl,compositionId,inputProps,+ output: outputFile,+ frame,imageFormat,- outputFile,+ jpegQuality,+ envVariables,+ overwrite,+ browserExecutable: browserExecutable ?? null,+ chromiumOptions,+ scale,+ logLevel,+ timeoutInMilliseconds,+ binariesDirectory: binariesDirectory ?? null,+ chromeMode,+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,+ mediaCacheSizeInBytes: mediaCacheSizeInBytes ?? null,+ offthreadVideoThreads: offthreadVideoThreads ?? null,+ licenseKey: licenseKey ?? null,};+ await sandbox.writeFiles([+ {+ path: 'render-still.ts',+ content: Buffer.from(renderStillScript),+ },+ ]);+const renderCmd = await sandbox.runCommand({cmd: 'node',args: ['--strip-types', 'render-still.ts', JSON.stringify(renderConfig)],diff --git a/packages/vercel/src/render-video-on-vercel.ts b/packages/vercel/src/render-video-on-vercel.tsindex 4fb0072c95..75a84680b9 100644--- a/packages/vercel/src/render-video-on-vercel.ts+++ b/packages/vercel/src/render-video-on-vercel.ts@@ -1,41 +1,170 @@import type {Sandbox} from '@vercel/sandbox';import {script as renderVideoScript} from './internals/render-video-script';-import type {RenderOnVercelProgress} from './types';+import type {+ AudioCodec,+ Bitrate,+ ChromeMode,+ ChromiumOptions,+ Codec,+ ColorSpace,+ FrameRange,+ HardwareAccelerationOption,+ LogLevel,+ PixelFormat,+ ProResProfile,+ RenderOnVercelProgress,+ VideoImageFormat,+ X264Preset,+} from './types';export async function renderVideoOnVercel({sandbox,compositionId,inputProps,- codec = 'h264',- outputFile = '/tmp/video.mp4',onProgress,bundleDir = '.remotion',+ outputFile = '/tmp/video.mp4',+ codec = 'h264',+ crf,+ imageFormat,+ pixelFormat,+ envVariables = {},+ frameRange,+ everyNthFrame = 1,+ overwrite = true,+ proResProfile,+ chromiumOptions = {},+ scale = 1,+ browserExecutable,+ preferLossless = false,+ enforceAudioTrack = false,+ disallowParallelEncoding = false,+ concurrency,+ binariesDirectory,+ metadata,+ licenseKey,+ videoBitrate,+ audioBitrate,+ encodingMaxRate,+ encodingBufferSize,+ muted = false,+ numberOfGifLoops,+ x264Preset,+ colorSpace = 'default',+ jpegQuality = 80,+ audioCodec,+ logLevel = 'info',+ timeoutInMilliseconds = 30000,+ forSeamlessAacConcatenation = false,+ separateAudioTo,+ hardwareAcceleration = 'disable',+ chromeMode = 'headless-shell',+ offthreadVideoCacheSizeInBytes,+ mediaCacheSizeInBytes,+ offthreadVideoThreads,+ repro = false,}: {sandbox: Sandbox;compositionId: string;inputProps: Record<string, unknown>;- codec?: string;- outputFile?: string;onProgress?: (progress: RenderOnVercelProgress) => void;bundleDir?: string;+ outputFile?: string;+ codec?: Codec;+ crf?: number | null;+ imageFormat?: VideoImageFormat | null;+ pixelFormat?: PixelFormat | null;+ envVariables?: Record<string, string>;+ frameRange?: FrameRange | null;+ everyNthFrame?: number;+ overwrite?: boolean;+ proResProfile?: ProResProfile;+ chromiumOptions?: ChromiumOptions;+ scale?: number;+ browserExecutable?: string | null;+ preferLossless?: boolean;+ enforceAudioTrack?: boolean;+ disallowParallelEncoding?: boolean;+ concurrency?: number | string | null;+ binariesDirectory?: string | null;+ metadata?: Record<string, string> | null;+ licenseKey?: string | null;+ videoBitrate?: Bitrate | null;+ audioBitrate?: Bitrate | null;+ encodingMaxRate?: Bitrate | null;+ encodingBufferSize?: Bitrate | null;+ muted?: boolean;+ numberOfGifLoops?: number | null;+ x264Preset?: X264Preset | null;+ colorSpace?: ColorSpace;+ jpegQuality?: number;+ audioCodec?: AudioCodec | null;+ logLevel?: LogLevel;+ timeoutInMilliseconds?: number;+ forSeamlessAacConcatenation?: boolean;+ separateAudioTo?: string | null;+ hardwareAcceleration?: HardwareAccelerationOption;+ chromeMode?: ChromeMode;+ offthreadVideoCacheSizeInBytes?: number | null;+ mediaCacheSizeInBytes?: number | null;+ offthreadVideoThreads?: number | null;+ repro?: boolean;}): Promise<{file: string}> {const serveUrl = `/vercel/sandbox/${bundleDir}`;- await sandbox.writeFiles([- {- path: 'render-video.ts',- content: Buffer.from(renderVideoScript),- },- ]);-const renderConfig = {serveUrl,compositionId,inputProps,+ outputLocation: outputFile,codec,- outputFile,+ crf: crf ?? null,+ imageFormat: imageFormat ?? null,+ pixelFormat: pixelFormat ?? null,+ envVariables,+ frameRange: frameRange ?? null,+ everyNthFrame,+ overwrite,+ proResProfile: proResProfile ?? null,+ chromiumOptions,+ scale,+ browserExecutable: browserExecutable ?? null,+ preferLossless,+ enforceAudioTrack,+ disallowParallelEncoding,+ concurrency: concurrency ?? null,+ binariesDirectory: binariesDirectory ?? null,+ metadata: metadata ?? null,+ licenseKey: licenseKey ?? null,+ videoBitrate: videoBitrate ?? null,+ audioBitrate: audioBitrate ?? null,+ encodingMaxRate: encodingMaxRate ?? null,+ encodingBufferSize: encodingBufferSize ?? null,+ muted,+ numberOfGifLoops: numberOfGifLoops ?? null,+ x264Preset: x264Preset ?? null,+ colorSpace,+ jpegQuality,+ audioCodec: audioCodec ?? null,+ logLevel,+ timeoutInMilliseconds,+ forSeamlessAacConcatenation,+ separateAudioTo: separateAudioTo ?? null,+ hardwareAcceleration,+ chromeMode,+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,+ mediaCacheSizeInBytes: mediaCacheSizeInBytes ?? null,+ offthreadVideoThreads: offthreadVideoThreads ?? null,+ repro,};+ await sandbox.writeFiles([+ {+ path: 'render-video.ts',+ content: Buffer.from(renderVideoScript),+ },+ ]);+const renderCmd = await sandbox.runCommand({cmd: 'node',args: ['--strip-types', 'render-video.ts', JSON.stringify(renderConfig)],@@ -53,7 +182,13 @@ export async function renderVideoOnVercel({} else if (message.type === 'progress') {onProgress?.({type: 'render-progress',+ renderedFrames: message.renderedFrames,+ encodedFrames: message.encodedFrames,+ encodedDoneIn: message.encodedDoneIn,+ renderedDoneIn: message.renderedDoneIn,+ renderEstimatedTime: message.renderEstimatedTime,progress: message.progress,+ stitchStage: message.stitchStage,});}} catch {diff --git a/packages/vercel/src/scripts/render-still.ts b/packages/vercel/src/scripts/render-still.tsindex 949e426640..bdaa0b9b7a 100644--- a/packages/vercel/src/scripts/render-still.ts+++ b/packages/vercel/src/scripts/render-still.ts@@ -1,32 +1,141 @@-import {openBrowser, renderStill, selectComposition} from '@remotion/renderer';+import {RenderInternals} from '@remotion/renderer';import {statSync} from 'fs';+import {NoReactInternals} from 'remotion/no-react';-const config = JSON.parse(process.argv[2]);+type InternalStillOptions = Parameters<+ typeof RenderInternals.internalRenderStill+>[0];++type RenderStillConfig = {+ compositionId: string;+ inputProps: Record<string, unknown>;+ output: InternalStillOptions['output'];+ serveUrl: InternalStillOptions['serveUrl'];+ frame: InternalStillOptions['frame'];+ imageFormat: InternalStillOptions['imageFormat'];+ jpegQuality: InternalStillOptions['jpegQuality'];+ envVariables: InternalStillOptions['envVariables'];+ overwrite: InternalStillOptions['overwrite'];+ browserExecutable: InternalStillOptions['browserExecutable'];+ chromiumOptions: InternalStillOptions['chromiumOptions'];+ scale: InternalStillOptions['scale'];+ logLevel: InternalStillOptions['logLevel'];+ timeoutInMilliseconds: InternalStillOptions['timeoutInMilliseconds'];+ binariesDirectory: InternalStillOptions['binariesDirectory'];+ chromeMode: InternalStillOptions['chromeMode'];+ offthreadVideoCacheSizeInBytes: InternalStillOptions['offthreadVideoCacheSizeInBytes'];+ mediaCacheSizeInBytes: InternalStillOptions['mediaCacheSizeInBytes'];+ offthreadVideoThreads: InternalStillOptions['offthreadVideoThreads'];+ licenseKey: InternalStillOptions['licenseKey'];+};++const config: RenderStillConfig = JSON.parse(process.argv[2]);++const noop = () => undefined;try {+ const serializedInputProps = NoReactInternals.serializeJSONWithSpecialTypes({+ data: config.inputProps,+ indent: undefined,+ staticBase: null,+ }).serializedString;+console.log(JSON.stringify({type: 'opening-browser'}));- const browser = await openBrowser('chrome');- console.log(JSON.stringify({type: 'selecting-composition'}));- const composition = await selectComposition({- serveUrl: config.serveUrl,- id: config.compositionId,- inputProps: config.inputProps,- puppeteerInstance: browser,++ const browser = await RenderInternals.internalOpenBrowser({+ browser: 'chrome',+ browserExecutable: config.browserExecutable,+ chromiumOptions: config.chromiumOptions,+ forceDeviceScaleFactor: undefined,+ viewport: null,+ indent: false,+ logLevel: config.logLevel,+ onBrowserDownload: () => ({+ version: null,+ onProgress: noop,+ }),+ chromeMode: config.chromeMode,});- await renderStill({+ console.log(JSON.stringify({type: 'selecting-composition'}));++ const {metadata: composition} =+ await RenderInternals.internalSelectComposition({+ serializedInputPropsWithCustomSchema: serializedInputProps,+ envVariables: config.envVariables,+ puppeteerInstance: browser,+ onBrowserLog: null,+ browserExecutable: config.browserExecutable,+ chromiumOptions: config.chromiumOptions,+ port: null,+ indent: false,+ server: undefined,+ serveUrl: config.serveUrl,+ id: config.compositionId,+ onServeUrlVisited: noop,+ logLevel: config.logLevel,+ timeoutInMilliseconds: config.timeoutInMilliseconds,+ binariesDirectory: config.binariesDirectory,+ onBrowserDownload: () => ({+ version: null,+ onProgress: noop,+ }),+ chromeMode: config.chromeMode,+ mediaCacheSizeInBytes: config.mediaCacheSizeInBytes,+ offthreadVideoCacheSizeInBytes: config.offthreadVideoCacheSizeInBytes,+ offthreadVideoThreads: config.offthreadVideoThreads,+ });++ const serializedResolvedProps =+ NoReactInternals.serializeJSONWithSpecialTypes({+ data: composition.props,+ indent: undefined,+ staticBase: null,+ }).serializedString;++ await RenderInternals.internalRenderStill({+ output: config.output,composition,+ serializedInputPropsWithCustomSchema: serializedInputProps,+ serializedResolvedPropsWithCustomSchema: serializedResolvedProps,serveUrl: config.serveUrl,+ frame: config.frame,imageFormat: config.imageFormat,- output: config.outputFile,- inputProps: config.inputProps,+ jpegQuality: config.jpegQuality,+ envVariables: config.envVariables,+ overwrite: config.overwrite,+ browserExecutable: config.browserExecutable,+ chromiumOptions: config.chromiumOptions,+ scale: config.scale,+ logLevel: config.logLevel,+ timeoutInMilliseconds: config.timeoutInMilliseconds,+ binariesDirectory: config.binariesDirectory,+ chromeMode: config.chromeMode,+ offthreadVideoCacheSizeInBytes: config.offthreadVideoCacheSizeInBytes,+ mediaCacheSizeInBytes: config.mediaCacheSizeInBytes,+ offthreadVideoThreads: config.offthreadVideoThreads,+ licenseKey: config.licenseKey,+ // Non-serializable fields with defaultspuppeteerInstance: browser,+ onBrowserLog: null,+ onDownload: null,+ cancelSignal: null,+ indent: false,+ server: undefined,+ port: null,+ onArtifact: null,+ onLog: RenderInternals.defaultOnLog,+ isProduction: true,+ onBrowserDownload: () => ({+ version: null,+ onProgress: noop,+ }),});console.log(JSON.stringify({type: 'render-complete'}));await browser.close({silent: false});- const size = statSync(config.outputFile).size;+ const {size} = statSync(config.output ?? '/tmp/still.png');console.log(JSON.stringify({type: 'done', size}));} catch (err) {console.error((err as Error).message);diff --git a/packages/vercel/src/scripts/render-video.ts b/packages/vercel/src/scripts/render-video.tsindex 7e57d65fda..a8e9b86cf9 100644--- a/packages/vercel/src/scripts/render-video.ts+++ b/packages/vercel/src/scripts/render-video.ts@@ -1,35 +1,204 @@-import {openBrowser, renderMedia, selectComposition} from '@remotion/renderer';+import type {InternalRenderMediaOptions} from '@remotion/renderer';+import {RenderInternals} from '@remotion/renderer';import {statSync} from 'fs';+import {NoReactInternals} from 'remotion/no-react';-const config = JSON.parse(process.argv[2]);+type RenderVideoConfig = {+ compositionId: string;+ inputProps: Record<string, unknown>;+ outputLocation: InternalRenderMediaOptions['outputLocation'];+ serveUrl: InternalRenderMediaOptions['serveUrl'];+ crf: InternalRenderMediaOptions['crf'];+ imageFormat: InternalRenderMediaOptions['imageFormat'];+ pixelFormat: InternalRenderMediaOptions['pixelFormat'];+ envVariables: InternalRenderMediaOptions['envVariables'];+ frameRange: InternalRenderMediaOptions['frameRange'];+ everyNthFrame: InternalRenderMediaOptions['everyNthFrame'];+ overwrite: InternalRenderMediaOptions['overwrite'];+ proResProfile: NonNullable<+ InternalRenderMediaOptions['proResProfile']+ > | null;+ chromiumOptions: InternalRenderMediaOptions['chromiumOptions'];+ scale: InternalRenderMediaOptions['scale'];+ browserExecutable: InternalRenderMediaOptions['browserExecutable'];+ preferLossless: InternalRenderMediaOptions['preferLossless'];+ enforceAudioTrack: InternalRenderMediaOptions['enforceAudioTrack'];+ disallowParallelEncoding: InternalRenderMediaOptions['disallowParallelEncoding'];+ concurrency: InternalRenderMediaOptions['concurrency'];+ binariesDirectory: InternalRenderMediaOptions['binariesDirectory'];+ metadata: InternalRenderMediaOptions['metadata'];+ licenseKey: InternalRenderMediaOptions['licenseKey'];+ codec: InternalRenderMediaOptions['codec'];+ videoBitrate: InternalRenderMediaOptions['videoBitrate'];+ audioBitrate: InternalRenderMediaOptions['audioBitrate'];+ encodingMaxRate: InternalRenderMediaOptions['encodingMaxRate'];+ encodingBufferSize: InternalRenderMediaOptions['encodingBufferSize'];+ muted: InternalRenderMediaOptions['muted'];+ numberOfGifLoops: InternalRenderMediaOptions['numberOfGifLoops'];+ x264Preset: InternalRenderMediaOptions['x264Preset'];+ colorSpace: InternalRenderMediaOptions['colorSpace'];+ jpegQuality: InternalRenderMediaOptions['jpegQuality'];+ audioCodec: InternalRenderMediaOptions['audioCodec'];+ logLevel: InternalRenderMediaOptions['logLevel'];+ timeoutInMilliseconds: InternalRenderMediaOptions['timeoutInMilliseconds'];+ forSeamlessAacConcatenation: InternalRenderMediaOptions['forSeamlessAacConcatenation'];+ separateAudioTo: InternalRenderMediaOptions['separateAudioTo'];+ hardwareAcceleration: InternalRenderMediaOptions['hardwareAcceleration'];+ chromeMode: InternalRenderMediaOptions['chromeMode'];+ offthreadVideoCacheSizeInBytes: InternalRenderMediaOptions['offthreadVideoCacheSizeInBytes'];+ mediaCacheSizeInBytes: InternalRenderMediaOptions['mediaCacheSizeInBytes'];+ offthreadVideoThreads: InternalRenderMediaOptions['offthreadVideoThreads'];+ repro: InternalRenderMediaOptions['repro'];+};++const config: RenderVideoConfig = JSON.parse(process.argv[2]);++const noop = () => undefined;try {+ const serializedInputProps = NoReactInternals.serializeJSONWithSpecialTypes({+ data: config.inputProps,+ indent: undefined,+ staticBase: null,+ }).serializedString;+console.log(JSON.stringify({type: 'opening-browser'}));- const browser = await openBrowser('chrome');- console.log(JSON.stringify({type: 'selecting-composition'}));- const composition = await selectComposition({- serveUrl: config.serveUrl,- id: config.compositionId,- inputProps: config.inputProps,- puppeteerInstance: browser,++ const browser = await RenderInternals.internalOpenBrowser({+ browser: 'chrome',+ browserExecutable: config.browserExecutable,+ chromiumOptions: config.chromiumOptions,+ forceDeviceScaleFactor: undefined,+ viewport: null,+ indent: false,+ logLevel: config.logLevel,+ onBrowserDownload: () => ({+ version: null,+ onProgress: noop,+ }),+ chromeMode: config.chromeMode,});- await renderMedia({+ console.log(JSON.stringify({type: 'selecting-composition'}));++ const {metadata: composition} =+ await RenderInternals.internalSelectComposition({+ serializedInputPropsWithCustomSchema: serializedInputProps,+ envVariables: config.envVariables,+ puppeteerInstance: browser,+ onBrowserLog: null,+ browserExecutable: config.browserExecutable,+ chromiumOptions: config.chromiumOptions,+ port: null,+ indent: false,+ server: undefined,+ serveUrl: config.serveUrl,+ id: config.compositionId,+ onServeUrlVisited: noop,+ logLevel: config.logLevel,+ timeoutInMilliseconds: config.timeoutInMilliseconds,+ binariesDirectory: config.binariesDirectory,+ onBrowserDownload: () => ({+ version: null,+ onProgress: noop,+ }),+ chromeMode: config.chromeMode,+ mediaCacheSizeInBytes: config.mediaCacheSizeInBytes,+ offthreadVideoCacheSizeInBytes: config.offthreadVideoCacheSizeInBytes,+ offthreadVideoThreads: config.offthreadVideoThreads,+ });++ const serializedResolvedProps =+ NoReactInternals.serializeJSONWithSpecialTypes({+ data: composition.props,+ indent: undefined,+ staticBase: null,+ }).serializedString;++ await RenderInternals.internalRenderMedia({+ outputLocation: config.outputLocation,composition,+ serializedInputPropsWithCustomSchema: serializedInputProps,+ serializedResolvedPropsWithCustomSchema: serializedResolvedProps,serveUrl: config.serveUrl,codec: config.codec,- outputLocation: config.outputFile,- inputProps: config.inputProps,- onProgress: ({progress}) => {- console.log(JSON.stringify({type: 'progress', progress}));- },+ crf: config.crf,+ imageFormat: config.imageFormat,+ pixelFormat: config.pixelFormat,+ envVariables: config.envVariables,+ frameRange: config.frameRange,+ everyNthFrame: config.everyNthFrame,+ overwrite: config.overwrite,+ proResProfile: config.proResProfile ?? undefined,+ chromiumOptions: config.chromiumOptions,+ scale: config.scale,+ browserExecutable: config.browserExecutable,+ preferLossless: config.preferLossless,+ enforceAudioTrack: config.enforceAudioTrack,+ disallowParallelEncoding: config.disallowParallelEncoding,+ concurrency: config.concurrency,+ binariesDirectory: config.binariesDirectory,+ metadata: config.metadata,+ licenseKey: config.licenseKey,+ videoBitrate: config.videoBitrate,+ audioBitrate: config.audioBitrate,+ encodingMaxRate: config.encodingMaxRate,+ encodingBufferSize: config.encodingBufferSize,+ muted: config.muted,+ numberOfGifLoops: config.numberOfGifLoops,+ x264Preset: config.x264Preset,+ colorSpace: config.colorSpace,+ jpegQuality: config.jpegQuality,+ audioCodec: config.audioCodec,+ logLevel: config.logLevel,+ timeoutInMilliseconds: config.timeoutInMilliseconds,+ forSeamlessAacConcatenation: config.forSeamlessAacConcatenation,+ separateAudioTo: config.separateAudioTo,+ hardwareAcceleration: config.hardwareAcceleration,+ chromeMode: config.chromeMode,+ offthreadVideoCacheSizeInBytes: config.offthreadVideoCacheSizeInBytes,+ mediaCacheSizeInBytes: config.mediaCacheSizeInBytes,+ offthreadVideoThreads: config.offthreadVideoThreads,+ repro: config.repro,+ // Non-serializable fields with defaultspuppeteerInstance: browser,+ onProgress: (progress) => {+ console.log(+ JSON.stringify({+ type: 'progress',+ renderedFrames: progress.renderedFrames,+ encodedFrames: progress.encodedFrames,+ encodedDoneIn: progress.encodedDoneIn,+ renderedDoneIn: progress.renderedDoneIn,+ renderEstimatedTime: progress.renderEstimatedTime,+ progress: progress.progress,+ stitchStage: progress.stitchStage,+ }),+ );+ },+ onDownload: () => undefined,+ onBrowserLog: null,+ onStart: noop,+ port: null,+ cancelSignal: undefined,+ onCtrlCExit: noop,+ indent: false,+ server: undefined,+ ffmpegOverride: undefined,+ compositionStart: 0,+ onArtifact: null,+ onLog: RenderInternals.defaultOnLog,+ isProduction: true,+ onBrowserDownload: () => ({+ version: null,+ onProgress: noop,+ }),});console.log(JSON.stringify({type: 'render-complete'}));await browser.close({silent: false});- const size = statSync(config.outputFile).size;+ const {size} = statSync(config.outputLocation ?? '/tmp/video.mp4');console.log(JSON.stringify({type: 'done', size}));} catch (err) {console.error((err as Error).message);diff --git a/packages/vercel/src/types.ts b/packages/vercel/src/types.tsindex f3d2d9f586..eb828c5351 100644--- a/packages/vercel/src/types.ts+++ b/packages/vercel/src/types.ts@@ -7,9 +7,101 @@ export type CreateSandboxOnProgress = (update: {message: string;}) => void;+// Render option types (compatible with @remotion/renderer)++export type Codec =+ | 'h264'+ | 'h265'+ | 'vp8'+ | 'vp9'+ | 'mp3'+ | 'aac'+ | 'wav'+ | 'prores'+ | 'h264-mkv'+ | 'h264-ts'+ | 'gif';++export type VideoImageFormat = 'png' | 'jpeg' | 'none';++export type StillImageFormat = 'png' | 'jpeg' | 'pdf' | 'webp';++export type PixelFormat =+ | 'yuv420p'+ | 'yuva420p'+ | 'yuv422p'+ | 'yuv444p'+ | 'yuv420p10le'+ | 'yuv422p10le'+ | 'yuv444p10le'+ | 'yuva444p10le';++export type ColorSpace = 'default' | 'bt601' | 'bt709' | 'bt2020-ncl';++export type AudioCodec = 'pcm-16' | 'aac' | 'mp3' | 'opus';++export type LogLevel = 'trace' | 'verbose' | 'info' | 'warn' | 'error';++export type ProResProfile =+ | '4444-xq'+ | '4444'+ | 'hq'+ | 'standard'+ | 'light'+ | 'proxy';++export type ChromeMode = 'headless-shell' | 'chrome-for-testing';++export type HardwareAccelerationOption = 'disable' | 'if-possible' | 'required';++export type X264Preset =+ | 'ultrafast'+ | 'superfast'+ | 'veryfast'+ | 'faster'+ | 'fast'+ | 'medium'+ | 'slow'+ | 'slower'+ | 'veryslow'+ | 'placebo';++export type OpenGlRenderer =+ | 'swangle'+ | 'angle'+ | 'egl'+ | 'swiftshader'+ | 'vulkan'+ | 'angle-egl';++export type FrameRange = number | [number, number] | [number, null];++type BitrateUnit = 'k' | 'K' | 'M';+export type Bitrate = `${number}${BitrateUnit}`;++export type ChromiumOptions = {+ ignoreCertificateErrors?: boolean;+ disableWebSecurity?: boolean;+ gl?: OpenGlRenderer | null;+ userAgent?: string | null;+ enableMultiProcessOnLinux?: boolean;+ darkMode?: boolean;+};++export type StitchingState = 'encoding' | 'muxing';+export type RenderOnVercelProgress =| {type: 'opening-browser'}| {type: 'selecting-composition'}- | {type: 'render-progress'; progress: number}+ | {+ type: 'render-progress';+ renderedFrames: number;+ encodedFrames: number;+ encodedDoneIn: number | null;+ renderedDoneIn: number | null;+ renderEstimatedTime: number;+ progress: number;+ stitchStage: StitchingState;+ }| {type: 'uploading'}| {type: 'done'; url: string; size: number};