🎥 Make videos programmatically with React
get started with scoping downloads
Jonny Burgerc55fe91499b2
diff --git a/packages/core/src/CompositionManager.tsx b/packages/core/src/CompositionManager.tsxindex 02673bb1a0..78856e1be7 100644--- a/packages/core/src/CompositionManager.tsx+++ b/packages/core/src/CompositionManager.tsx@@ -78,11 +78,30 @@ export type TAsset = {playbackRate: number;};+export type DownloadMap = {+ isDownloadingMap: {+ [src: string]:+ | {+ [downloadDir: string]: boolean;+ }+ | undefined;+ };+ hasBeenDownloadedMap: {+ [src: string]:+ | {+ [downloadDir: string]: string | null;+ }+ | undefined;+ };+ listeners: {[key: string]: {[downloadDir: string]: (() => void)[]}};+};+export type RenderAssetInfo = {assets: TAsset[][];imageSequenceName: string;downloadDir: string;firstFrameIndex: number;+ downloadMap: DownloadMap;};export type CompositionManagerContext = {diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex fe1023b4bd..b37440a83c 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -43,7 +43,12 @@ checkMultipleRemotionVersions();export * from './AbsoluteFill';export * from './audio';export * from './Composition';-export {SmallTCompMetadata, TAsset, TCompMetadata} from './CompositionManager';+export {+ DownloadMap,+ SmallTCompMetadata,+ TAsset,+ TCompMetadata,+} from './CompositionManager';export {Config, ConfigType} from './config';export {getInputProps} from './config/input-props';export * from './delay-render';diff --git a/packages/core/src/video/OffthreadVideoForRendering.tsx b/packages/core/src/video/OffthreadVideoForRendering.tsxindex 4a7428b2a4..0d08e7fc2a 100644--- a/packages/core/src/video/OffthreadVideoForRendering.tsx+++ b/packages/core/src/video/OffthreadVideoForRendering.tsx@@ -76,6 +76,7 @@ export const OffthreadVideoForRendering: React.FC<OffthreadVideoProps> = ({return;}+ console.log('REGISTERING', src);registerAsset({type: 'video',src: getAbsoluteSrc(src),diff --git a/packages/lambda/src/functions/helpers/print-cloudwatch-helper.ts b/packages/lambda/src/functions/helpers/print-cloudwatch-helper.tsindex 3d6dc64edf..b68df250bc 100644--- a/packages/lambda/src/functions/helpers/print-cloudwatch-helper.ts+++ b/packages/lambda/src/functions/helpers/print-cloudwatch-helper.ts@@ -2,7 +2,7 @@ import type {LambdaRoutines} from '../../defaults';export const printCloudwatchHelper = (type: LambdaRoutines,- data: Record<string, string>+ data: Record<string, string | boolean>) => {const d = Object.keys(data).reduce((a, b) => {return [...a, `${b}=${data[b]}`];diff --git a/packages/lambda/src/functions/index.ts b/packages/lambda/src/functions/index.tsindex 3e9bad4353..68e5b70d6d 100644--- a/packages/lambda/src/functions/index.ts+++ b/packages/lambda/src/functions/index.ts@@ -33,6 +33,7 @@ export const handler = async <T extends LambdaRoutines>(if (params.type === LambdaRoutines.still) {printCloudwatchHelper(LambdaRoutines.still, {inputProps: JSON.stringify(params.inputProps),+ isWarm,});return stillHandler(params, {expectedBucketOwner: currentUserId,@@ -42,6 +43,7 @@ export const handler = async <T extends LambdaRoutines>(if (params.type === LambdaRoutines.start) {printCloudwatchHelper(LambdaRoutines.start, {inputProps: JSON.stringify(params.inputProps),+ isWarm,});return startHandler(params);}@@ -50,6 +52,7 @@ export const handler = async <T extends LambdaRoutines>(printCloudwatchHelper(LambdaRoutines.launch, {renderId: params.renderId,inputProps: JSON.stringify(params.inputProps),+ isWarm,});return launchHandler(params, {expectedBucketOwner: currentUserId});}@@ -57,6 +60,7 @@ export const handler = async <T extends LambdaRoutines>(if (params.type === LambdaRoutines.status) {printCloudwatchHelper(LambdaRoutines.status, {renderId: params.renderId,+ isWarm,});return progressHandler(params, {expectedBucketOwner: currentUserId,@@ -72,6 +76,7 @@ export const handler = async <T extends LambdaRoutines>(RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose')),inputProps: JSON.stringify(params.inputProps),+ isWarm,});return rendererHandler(params, {expectedBucketOwner: currentUserId,@@ -80,7 +85,9 @@ export const handler = async <T extends LambdaRoutines>(}if (params.type === LambdaRoutines.info) {- printCloudwatchHelper(LambdaRoutines.info, {});+ printCloudwatchHelper(LambdaRoutines.info, {+ isWarm,+ });return infoHandler(params);}diff --git a/packages/renderer/src/assets/convert-assets-to-file-urls.ts b/packages/renderer/src/assets/convert-assets-to-file-urls.tsindex e92140b014..34aef8f199 100644--- a/packages/renderer/src/assets/convert-assets-to-file-urls.ts+++ b/packages/renderer/src/assets/convert-assets-to-file-urls.ts@@ -1,4 +1,4 @@-import type {TAsset} from 'remotion';+import type {DownloadMap, TAsset} from 'remotion';import type {RenderMediaOnDownload} from './download-and-map-assets-to-file';import {downloadAndMapAssetsToFileUrl} from './download-and-map-assets-to-file';@@ -14,10 +14,12 @@ export const convertAssetsToFileUrls = async ({assets,downloadDir,onDownload,+ downloadMap,}: {assets: TAsset[][];downloadDir: string;onDownload: RenderMediaOnDownload;+ downloadMap: DownloadMap;}): Promise<TAsset[][]> => {const chunks = chunk(assets, 1000);const results: TAsset[][][] = [];@@ -31,6 +33,7 @@ export const convertAssetsToFileUrls = async ({asset: a,downloadDir,onDownload,+ downloadMap,});}));diff --git a/packages/renderer/src/assets/download-and-map-assets-to-file.ts b/packages/renderer/src/assets/download-and-map-assets-to-file.tsindex e7bbc56a1f..e8c7a14497 100644--- a/packages/renderer/src/assets/download-and-map-assets-to-file.ts+++ b/packages/renderer/src/assets/download-and-map-assets-to-file.ts@@ -1,6 +1,6 @@import fs from 'fs';import path from 'path';-import type {TAsset} from 'remotion';+import type {DownloadMap, TAsset} from 'remotion';import {random} from 'remotion';import {isAssetCompressed} from '../compress-assets';import {ensureOutputDirectory} from '../ensure-output-directory';@@ -18,36 +18,40 @@ export type RenderMediaOnDownload = (| undefined| void;-const isDownloadingMap: {- [src: string]: {[downloadDir: string]: boolean} | undefined;-} = {};-const hasBeenDownloadedMap: {- [src: string]: {[downloadDir: string]: string | null} | undefined;-} = {};-const listeners: {[key: string]: {[downloadDir: string]: (() => void)[]}} = {};+export const makeDownloadMap = (): DownloadMap => {+ return {+ isDownloadingMap: {},+ hasBeenDownloadedMap: {},+ listeners: {},+ };+};const waitForAssetToBeDownloaded = ({src,downloadDir,+ downloadMap,}: {src: string;downloadDir: string;+ downloadMap: DownloadMap;}): Promise<string> => {- if (hasBeenDownloadedMap[src]?.[downloadDir]) {- return Promise.resolve(hasBeenDownloadedMap[src]?.[downloadDir] as string);+ if (downloadMap.hasBeenDownloadedMap[src]?.[downloadDir]) {+ return Promise.resolve(+ downloadMap.hasBeenDownloadedMap[src]?.[downloadDir] as string+ );}- if (!listeners[src]) {- listeners[src] = {};+ if (!downloadMap.listeners[src]) {+ downloadMap.listeners[src] = {};}- if (!listeners[src][downloadDir]) {- listeners[src][downloadDir] = [];+ if (!downloadMap.listeners[src][downloadDir]) {+ downloadMap.listeners[src][downloadDir] = [];}return new Promise<string>((resolve) => {- listeners[src][downloadDir].push(() => {- const srcMap = hasBeenDownloadedMap[src];+ downloadMap.listeners[src][downloadDir].push(() => {+ const srcMap = downloadMap.hasBeenDownloadedMap[src];if (!srcMap || !srcMap[downloadDir]) {throw new Error('Expected file for ' + src + 'to be available in ' + downloadDir@@ -63,40 +67,42 @@ const notifyAssetIsDownloaded = ({src,downloadDir,to,+ downloadMap,}: {src: string;downloadDir: string;to: string;+ downloadMap: DownloadMap;}) => {- if (!listeners[src]) {- listeners[src] = {};+ if (!downloadMap.listeners[src]) {+ downloadMap.listeners[src] = {};}- if (!listeners[src][downloadDir]) {- listeners[src][downloadDir] = [];+ if (!downloadMap.listeners[src][downloadDir]) {+ downloadMap.listeners[src][downloadDir] = [];}- if (!isDownloadingMap[src]) {- isDownloadingMap[src] = {};+ if (!downloadMap.isDownloadingMap[src]) {+ downloadMap.isDownloadingMap[src] = {};}(- isDownloadingMap[src] as {+ downloadMap.isDownloadingMap[src] as {[downloadDir: string]: boolean;}- )[downloadDir] = true;+ )[downloadDir] = false;- if (!hasBeenDownloadedMap[src]) {- hasBeenDownloadedMap[src] = {};+ if (!downloadMap.hasBeenDownloadedMap[src]) {+ downloadMap.hasBeenDownloadedMap[src] = {};}(- hasBeenDownloadedMap[src] as {+ downloadMap.hasBeenDownloadedMap[src] as {[downloadDir: string]: string | null;})[downloadDir] = to;- listeners[src][downloadDir].forEach((fn) => fn());+ downloadMap.listeners[src][downloadDir].forEach((fn) => fn());};const validateMimeType = (mimeType: string, src: string) => {@@ -147,44 +153,53 @@ export const downloadAsset = async ({src,onDownload,downloadDir,+ downloadMap,}: {src: string;onDownload: RenderMediaOnDownload;downloadDir: string;+ downloadMap: DownloadMap;}): Promise<string> => {if (isAssetCompressed(src)) {return src;}- if (hasBeenDownloadedMap[src]?.[downloadDir]) {- const claimedDownloadLocation = hasBeenDownloadedMap[src]?.[+ if (downloadMap.hasBeenDownloadedMap[src]?.[downloadDir]) {+ const claimedDownloadLocation = downloadMap.hasBeenDownloadedMap[src]?.[downloadDir] as string;+ console.log(+ 'HAS BEEN DL',+ src,+ claimedDownloadLocation,+ fs.existsSync(claimedDownloadLocation)+ );// The OS might have deleted the file since even though we marked it as downloaded. In that case we reset the state and download it againif (fs.existsSync(claimedDownloadLocation)) {return claimedDownloadLocation;}// eslint-disable-next-line @typescript-eslint/no-non-null-assertion- hasBeenDownloadedMap[src]![downloadDir] = null;- if (!isDownloadingMap[src]) {- isDownloadingMap[src] = {};+ downloadMap.hasBeenDownloadedMap[src]![downloadDir] = null;+ if (!downloadMap.isDownloadingMap[src]) {+ downloadMap.isDownloadingMap[src] = {};}// eslint-disable-next-line @typescript-eslint/no-non-null-assertion- isDownloadingMap[src]![downloadDir] = false;+ downloadMap.isDownloadingMap[src]![downloadDir] = false;}- if (isDownloadingMap[src]?.[downloadDir]) {- return waitForAssetToBeDownloaded({src, downloadDir});+ if (downloadMap.isDownloadingMap[src]?.[downloadDir]) {+ console.log('TRIGGER WAIT', {src, downloadDir});+ return waitForAssetToBeDownloaded({downloadMap, src, downloadDir});}- if (!isDownloadingMap[src]) {- isDownloadingMap[src] = {};+ if (!downloadMap.isDownloadingMap[src]) {+ downloadMap.isDownloadingMap[src] = {};}(- isDownloadingMap[src] as {+ downloadMap.isDownloadingMap[src] as {[downloadDir: string]: boolean;})[downloadDir] = true;@@ -216,10 +231,11 @@ export const downloadAsset = async ({const buff = Buffer.from(assetData, encoding);await fs.promises.writeFile(output, buff);- notifyAssetIsDownloaded({src, downloadDir, to: output});+ notifyAssetIsDownloaded({src, downloadMap, downloadDir, to: output});return output;}+ console.log('STARTING DL', {src, downloadDir});const {to} = await downloadFile({url: src,onProgress: (progress) => {@@ -228,18 +244,19 @@ export const downloadAsset = async ({to: (contentDisposition) =>getSanitizedFilenameForAssetUrl({contentDisposition, downloadDir, src}),});- notifyAssetIsDownloaded({src, downloadDir, to});++ notifyAssetIsDownloaded({src, downloadMap, downloadDir, to});return to;};-export const markAllAssetsAsDownloaded = () => {- Object.keys(hasBeenDownloadedMap).forEach((key) => {- delete hasBeenDownloadedMap[key];+export const markAllAssetsAsDownloaded = (downloadMap: DownloadMap) => {+ Object.keys(downloadMap.hasBeenDownloadedMap).forEach((key) => {+ delete downloadMap.hasBeenDownloadedMap[key];});- Object.keys(isDownloadingMap).forEach((key) => {- delete isDownloadingMap[key];+ Object.keys(downloadMap.isDownloadingMap).forEach((key) => {+ delete downloadMap.isDownloadingMap[key];});};@@ -307,15 +324,18 @@ export const downloadAndMapAssetsToFileUrl = async ({asset,downloadDir,onDownload,+ downloadMap,}: {asset: TAsset;downloadDir: string;onDownload: RenderMediaOnDownload;+ downloadMap: DownloadMap;}): Promise<TAsset> => {const newSrc = await downloadAsset({src: asset.src,downloadDir,onDownload,+ downloadMap,});return {diff --git a/packages/renderer/src/assets/download-file.ts b/packages/renderer/src/assets/download-file.tsindex 0732b3e583..19886fd7b7 100644--- a/packages/renderer/src/assets/download-file.ts+++ b/packages/renderer/src/assets/download-file.ts@@ -1,7 +1,11 @@import {createWriteStream} from 'fs';import {ensureOutputDirectory} from '../ensure-output-directory';+import {getTmpDirStateIfENoSp} from './get-files-in-folder';import {readFile} from './read-file';+let data = 0;+let downloads = 0;+export const downloadFile = ({onProgress,url,@@ -40,12 +44,21 @@ export const downloadFile = ({percent: 1,totalSize: downloaded,});+ downloads++;+ console.log(+ 'TOTAL DOWNLOADED',+ url,+ downloads,+ data,+ getTmpDirStateIfENoSp()+ );return resolve({sizeInBytes: downloaded, to});});writeStream.on('error', (err) => reject(err));res.pipe(writeStream).on('error', (err) => reject(err));res.on('data', (d) => {downloaded += d.length;+ data += d.length;onProgress?.({downloaded,percent: totalSize === null ? null : downloaded / totalSize,diff --git a/packages/renderer/src/assets/get-files-in-folder.ts b/packages/renderer/src/assets/get-files-in-folder.tsnew file mode 100644index 0000000000..2e17222007--- /dev/null+++ b/packages/renderer/src/assets/get-files-in-folder.ts@@ -0,0 +1,46 @@+import fs from 'fs';+import path from 'path';++export type FileNameAndSize = {+ filename: string;+ size: number;+};++export function getFolderFiles(folder: string) {+ const files = fs.readdirSync(folder);+ const paths: FileNameAndSize[] = [];+ files.forEach((file) => {+ const full = path.join(folder, file);+ try {+ const stat = fs.statSync(full);+ if (stat.isDirectory()) {+ paths.push(...getFolderFiles(full));+ } else {+ paths.push({+ filename: full,+ size: stat.size,+ });+ }+ } catch (err) {+ if ((err as Error).message.includes('ENOENT')) {+ // Race condition: File was deleted in the meanwhile.+ // Do nothing+ } else {+ throw err;+ }+ }+ });+ return paths;+}++export const getTmpDirStateIfENoSp = () => {+ const files = getFolderFiles('/tmp');+ return {+ files: files+ .slice(0)+ .sort((a, b) => a.size - b.size)+ .reverse()+ .slice(0, 100),+ total: files.reduce((a, b) => a + b.size, 0),+ };+};diff --git a/packages/renderer/src/get-compositions.ts b/packages/renderer/src/get-compositions.tsindex 508485f042..88576d935d 100644--- a/packages/renderer/src/get-compositions.ts+++ b/packages/renderer/src/get-compositions.ts@@ -1,4 +1,5 @@import type {TCompMetadata} from 'remotion';+import {makeDownloadMap} from './assets/download-and-map-assets-to-file';import type {BrowserExecutable} from './browser-executable';import type {BrowserLog} from './browser-log';import type {Browser} from './browser/Browser';@@ -84,6 +85,7 @@ export const getCompositions = async (config?: GetCompositionsConfig) => {const downloadDir = makeAssetsDownloadTmpDir();+ const downloadMap = makeDownloadMap();const {page, cleanup} = await getPageAndCleanupFn({passedInInstance: config?.puppeteerInstance,@@ -109,6 +111,7 @@ export const getCompositions = async (ffmpegExecutable: config?.ffmpegExecutable ?? null,ffprobeExecutable: config?.ffprobeExecutable ?? null,port: config?.port ?? null,+ downloadMap,}).then(({serveUrl, closeServer, offthreadPort}) => {close = closeServer;diff --git a/packages/renderer/src/offthread-video-server.ts b/packages/renderer/src/offthread-video-server.tsindex f9630a6554..f7c4af0a31 100644--- a/packages/renderer/src/offthread-video-server.ts+++ b/packages/renderer/src/offthread-video-server.ts@@ -1,5 +1,5 @@import type {RequestListener} from 'http';-import type {OffthreadVideoImageFormat} from 'remotion';+import type {DownloadMap, OffthreadVideoImageFormat} from 'remotion';import {Internals} from 'remotion';import {URLSearchParams} from 'url';import type {RenderMediaOnDownload} from './assets/download-and-map-assets-to-file';@@ -48,12 +48,14 @@ export const startOffthreadVideoServer = ({downloadDir,onDownload,onError,+ downloadMap,}: {ffmpegExecutable: FfmpegExecutable;ffprobeExecutable: FfmpegExecutable;downloadDir: string;onDownload: RenderMediaOnDownload;onError: (err: Error) => void;+ downloadMap: DownloadMap;}): RequestListener => {return (req, res) => {if (!req.url) {@@ -73,14 +75,32 @@ export const startOffthreadVideoServer = ({`image/${imageFormat === 'jpeg' ? 'jpg' : 'png'}`);- downloadAsset({src, downloadDir, onDownload})+ Promise.race<string>([+ downloadAsset({src, downloadDir, onDownload, downloadMap}),+ new Promise((_, rej) => {+ setTimeout(() => rej(new Error(String('TIMEOUT FOR ' + src))), 15000);+ }),+ ]).then((to) => {- return extractFrameFromVideo({- time,- src: to,- ffmpegExecutable,- ffprobeExecutable,- imageFormat,+ const random = Math.random();+ console.time(src + random);+ return Promise.race([+ extractFrameFromVideo({+ time,+ src: to,+ ffmpegExecutable,+ ffprobeExecutable,+ imageFormat,+ }),+ new Promise((_, rej) => {+ setTimeout(+ () => rej(new Error(String('EXTRACTION TIMEDOUT FOR ' + src))),+ 15000+ );+ }),+ ]).then((a) => {+ console.timeEnd(src + random);+ return a;});}).then((readable) => {diff --git a/packages/renderer/src/prepare-server.ts b/packages/renderer/src/prepare-server.tsindex 0194991449..7ee7992c6a 100644--- a/packages/renderer/src/prepare-server.ts+++ b/packages/renderer/src/prepare-server.ts@@ -1,5 +1,6 @@import {existsSync} from 'fs';import path from 'path';+import type {DownloadMap} from 'remotion';import type {RenderMediaOnDownload} from './assets/download-and-map-assets-to-file';import type {FfmpegExecutable} from './ffmpeg-executable';import {isServeUrl} from './is-serve-url';@@ -14,6 +15,7 @@ export const prepareServer = async ({onError,webpackConfigOrServeUrl,port,+ downloadMap,}: {webpackConfigOrServeUrl: string;downloadDir: string;@@ -22,6 +24,7 @@ export const prepareServer = async ({ffmpegExecutable: FfmpegExecutable;ffprobeExecutable: FfmpegExecutable;port: number | null;+ downloadMap: DownloadMap;}): Promise<{serveUrl: string;closeServer: () => Promise<unknown>;@@ -35,6 +38,7 @@ export const prepareServer = async ({ffmpegExecutable,ffprobeExecutable,port,+ downloadMap,});return Promise.resolve({@@ -62,6 +66,7 @@ export const prepareServer = async ({ffmpegExecutable,ffprobeExecutable,port,+ downloadMap,});return Promise.resolve({closeServer: () => {diff --git a/packages/renderer/src/render-frames.ts b/packages/renderer/src/render-frames.tsindex 846aff5445..2d363be2d2 100644--- a/packages/renderer/src/render-frames.ts+++ b/packages/renderer/src/render-frames.ts@@ -3,7 +3,10 @@ import path from 'path';import type {SmallTCompMetadata, TAsset} from 'remotion';import {Internals} from 'remotion';import type {RenderMediaOnDownload} from './assets/download-and-map-assets-to-file';-import {downloadAndMapAssetsToFileUrl} from './assets/download-and-map-assets-to-file';+import {+ downloadAndMapAssetsToFileUrl,+ makeDownloadMap,+} from './assets/download-and-map-assets-to-file';import {DEFAULT_BROWSER} from './browser';import type {BrowserExecutable} from './browser-executable';import type {BrowserLog} from './browser-log';@@ -133,6 +136,7 @@ const innerRenderFrames = ({onDownload: RenderMediaOnDownload;proxyPort: number;}): Promise<RenderFramesOutput> => {+ const downloadMap = makeDownloadMap();if (!puppeteerInstance) {throw new Error('no puppeteer instance passed to innerRenderFrames - internal error'@@ -312,6 +316,7 @@ const innerRenderFrames = ({asset,downloadDir,onDownload,+ downloadMap,}).catch((err) => {onError(new Error(`Error while downloading asset: ${(err as Error).stack}`)@@ -334,6 +339,7 @@ const innerRenderFrames = ({downloadDir,imageSequenceName: `element-%0${filePadLength}d.${imageFormat}`,firstFrameIndex: framesToRender[0],+ downloadMap,},frameCount: framesToRender.length,};@@ -400,6 +406,7 @@ export const renderFrames = (});const downloadDir = makeAssetsDownloadTmpDir();+ const downloadMap = makeDownloadMap();const onDownload = options.onDownload ?? (() => () => undefined);@@ -428,6 +435,7 @@ export const renderFrames = (ffmpegExecutable: options.ffmpegExecutable ?? null,ffprobeExecutable: options.ffprobeExecutable ?? null,port: options.port ?? null,+ downloadMap,}),browserInstance,]).then(([{serveUrl, closeServer, offthreadPort}, puppeteerInstance]) => {diff --git a/packages/renderer/src/render-still.ts b/packages/renderer/src/render-still.tsindex 83a4b52ffc..e34df0e634 100644--- a/packages/renderer/src/render-still.ts+++ b/packages/renderer/src/render-still.ts@@ -3,6 +3,7 @@ import path from 'path';import type {SmallTCompMetadata} from 'remotion';import {Internals} from 'remotion';import type {RenderMediaOnDownload} from './assets/download-and-map-assets-to-file';+import {makeDownloadMap} from './assets/download-and-map-assets-to-file';import {DEFAULT_BROWSER} from './browser';import type {BrowserExecutable} from './browser-executable';import type {Browser as PuppeteerBrowser} from './browser/Browser';@@ -221,6 +222,7 @@ export const renderStill = (options: RenderStillOptions): Promise<void> => {const selectedServeUrl = getServeUrlWithFallback(options);const downloadDir = makeAssetsDownloadTmpDir();+ const downloadMap = makeDownloadMap();const onDownload = options.onDownload ?? (() => () => undefined);@@ -237,6 +239,7 @@ export const renderStill = (options: RenderStillOptions): Promise<void> => {ffmpegExecutable: options.ffmpegExecutable ?? null,ffprobeExecutable: options.ffprobeExecutable ?? null,port: options.port ?? null,+ downloadMap,}).then(({serveUrl, closeServer, offthreadPort}) => {close = closeServer;diff --git a/packages/renderer/src/serve-static.ts b/packages/renderer/src/serve-static.tsindex 42d80e2552..7701a251f5 100644--- a/packages/renderer/src/serve-static.ts+++ b/packages/renderer/src/serve-static.ts@@ -1,4 +1,5 @@import http from 'http';+import type {DownloadMap} from 'remotion';import type {RenderMediaOnDownload} from './assets/download-and-map-assets-to-file';import type {FfmpegExecutable} from './ffmpeg-executable';import {getDesiredPort} from './get-port';@@ -14,6 +15,7 @@ export const serveStatic = async (downloadDir: string;onDownload: RenderMediaOnDownload;onError: (err: Error) => void;+ downloadMap: DownloadMap;}): Promise<{port: number;@@ -27,6 +29,7 @@ export const serveStatic = async (downloadDir: options.downloadDir,onDownload: options.onDownload,onError: options.onError,+ downloadMap: options.downloadMap,});try {diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.tsindex 9a7d54edf6..4907ba0e4c 100644--- a/packages/renderer/src/stitch-frames-to-video.ts+++ b/packages/renderer/src/stitch-frames-to-video.ts@@ -2,7 +2,7 @@ import execa from 'execa';import fs, {unlinkSync} from 'fs';import {readFile} from 'fs/promises';import path from 'path';-import type {RenderAssetInfo, TAsset} from 'remotion';+import type {DownloadMap, RenderAssetInfo, TAsset} from 'remotion';import {Internals} from 'remotion';import {calculateAssetPositions} from './assets/calculate-asset-positions';import {convertAssetsToFileUrls} from './assets/convert-assets-to-file-urls';@@ -85,6 +85,7 @@ const getAssetsData = async ({ffmpegExecutable,ffprobeExecutable,onProgress,+ downloadMap,}: {assets: TAsset[][];downloadDir: string;@@ -95,14 +96,16 @@ const getAssetsData = async ({ffmpegExecutable: FfmpegExecutable | null;ffprobeExecutable: FfmpegExecutable | null;onProgress: (progress: number) => void;+ downloadMap: DownloadMap;}): Promise<string> => {const fileUrlAssets = await convertAssetsToFileUrls({assets,downloadDir,onDownload: onDownload ?? (() => () => undefined),+ downloadMap,});- markAllAssetsAsDownloaded();+ markAllAssetsAsDownloaded(downloadMap);const assetPositions: Assets = calculateAssetPositions(fileUrlAssets);if (verbose) {@@ -243,6 +246,7 @@ export const spawnFfmpeg = async (ffmpegExecutable: options.ffmpegExecutable ?? null,ffprobeExecutable: options.ffprobeExecutable ?? null,onProgress: (prog) => updateProgress(prog, 0),+ downloadMap: options.assetsInfo.downloadMap,}): null;