@remotion/renderer
Version:
Render Remotion videos using Node.js or Bun
54 lines (53 loc) • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.takeFrame = void 0;
const collect_assets_1 = require("./collect-assets");
const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
const puppeteer_screenshot_1 = require("./puppeteer-screenshot");
const takeFrame = async ({ freePage, imageFormat, jpegQuality, frame, width, height, output, scale, wantsBuffer, timeoutInMilliseconds, }) => {
var _a;
const collectedAssets = await (0, collect_assets_1.collectAssets)({
frame,
freePage,
timeoutInMilliseconds,
});
if (imageFormat === 'none') {
return { buffer: null, collectedAssets };
}
if (imageFormat === 'png' ||
imageFormat === 'pdf' ||
imageFormat === 'webp') {
await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
pageFunction: () => {
document.body.style.background = 'transparent';
},
args: [],
frame: null,
page: freePage,
timeoutInMilliseconds,
});
}
else {
await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
pageFunction: () => {
document.body.style.background = 'black';
},
args: [],
frame: null,
page: freePage,
timeoutInMilliseconds,
});
}
const buf = await (0, puppeteer_screenshot_1.screenshot)({
page: freePage,
omitBackground: imageFormat === 'png',
path: (_a = (wantsBuffer ? undefined : output)) !== null && _a !== void 0 ? _a : undefined,
type: imageFormat,
jpegQuality,
width,
height,
scale,
});
return { buffer: buf, collectedAssets };
};
exports.takeFrame = takeFrame;