UNPKG

@remotion/renderer

Version:

Render Remotion videos using Node.js or Bun

27 lines (26 loc) 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.shouldUseParallelEncoding = void 0; const get_available_memory_1 = require("./memory/get-available-memory"); const estimateMemoryUsageForPrestitcher = ({ width, height, }) => { // Empirically we detected that per 1 million pixels, FFMPEG uses around 1GB of memory, relatively independent of // the duration of the video. const memoryUsageFor4K = 1000000000; const memoryUsageOfPixel = memoryUsageFor4K / 1000000; return memoryUsageOfPixel * width * height; }; const shouldUseParallelEncoding = ({ width, height, logLevel, }) => { const freeMemory = (0, get_available_memory_1.getAvailableMemory)(logLevel); const estimatedUsage = estimateMemoryUsageForPrestitcher({ height, width, }); const hasEnoughMemory = freeMemory - estimatedUsage > 2000000000 && estimatedUsage / freeMemory < 0.5; return { hasEnoughMemory, freeMemory, estimatedUsage, }; }; exports.shouldUseParallelEncoding = shouldUseParallelEncoding;