UNPKG

@remotion/renderer

Version:

Render Remotion videos using Node.js or Bun

37 lines (36 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertAssetsToFileUrls = void 0; const download_and_map_assets_to_file_1 = require("./download-and-map-assets-to-file"); const chunk = (input, size) => { return input.reduce((arr, item, idx) => { return idx % size === 0 ? [...arr, [item]] : [...arr.slice(0, -1), [...arr.slice(-1)[0], item]]; }, []); }; const convertAssetsToFileUrls = async ({ assets, onDownload, downloadMap, indent, logLevel, binariesDirectory, }) => { const chunks = chunk(assets, 1000); const results = []; for (const ch of chunks) { const assetPromises = ch.map((frame) => { const frameAssetPromises = frame.audioAndVideoAssets.map((a) => { return (0, download_and_map_assets_to_file_1.downloadAndMapAssetsToFileUrl)({ renderAsset: a, onDownload, downloadMap, indent, logLevel, binariesDirectory, cancelSignalForAudioAnalysis: undefined, shouldAnalyzeAudioImmediately: true, }); }); return Promise.all(frameAssetPromises); }); const result = await Promise.all(assetPromises); results.push(result); } return results.flat(1); }; exports.convertAssetsToFileUrls = convertAssetsToFileUrls;