@shotstack/shotstack-canvas 1.5.7 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entry.node.cjs +23 -10
- package/dist/entry.node.js +23 -10
- package/package.json +1 -1
package/dist/entry.node.cjs
CHANGED
|
@@ -2318,16 +2318,29 @@ var VideoGenerator = class {
|
|
|
2318
2318
|
});
|
|
2319
2319
|
try {
|
|
2320
2320
|
const painter = await createNodePainter({ width, height, pixelRatio });
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
const
|
|
2324
|
-
|
|
2325
|
-
const
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2321
|
+
const CHUNK_SIZE = 30;
|
|
2322
|
+
for (let chunkStart = 0; chunkStart < totalFrames; chunkStart += CHUNK_SIZE) {
|
|
2323
|
+
const chunkEnd = Math.min(chunkStart + CHUNK_SIZE, totalFrames);
|
|
2324
|
+
const chunkSize = chunkEnd - chunkStart;
|
|
2325
|
+
const chunkOps = [];
|
|
2326
|
+
for (let frame = chunkStart; frame < chunkEnd; frame++) {
|
|
2327
|
+
const t = frame / (totalFrames - 1) * duration;
|
|
2328
|
+
chunkOps.push(await frameGenerator(t));
|
|
2329
|
+
}
|
|
2330
|
+
for (let i = 0; i < chunkSize; i++) {
|
|
2331
|
+
const frame = chunkStart + i;
|
|
2332
|
+
await painter.render(chunkOps[i]);
|
|
2333
|
+
const png = await painter.toPNG();
|
|
2334
|
+
const ok = ffmpeg.stdin.write(png);
|
|
2335
|
+
if (!ok) await new Promise((r) => ffmpeg.stdin.once("drain", r));
|
|
2336
|
+
if (frame % Math.max(1, Math.floor(fps / 2)) === 0) {
|
|
2337
|
+
const pct = Math.round((frame + 1) / totalFrames * 100);
|
|
2338
|
+
console.log(`\u{1F39E}\uFE0F Rendering frames: ${pct}%`);
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
chunkOps.length = 0;
|
|
2342
|
+
if (global.gc && chunkEnd < totalFrames) {
|
|
2343
|
+
global.gc();
|
|
2331
2344
|
}
|
|
2332
2345
|
}
|
|
2333
2346
|
ffmpeg.stdin.end();
|
package/dist/entry.node.js
CHANGED
|
@@ -2279,16 +2279,29 @@ var VideoGenerator = class {
|
|
|
2279
2279
|
});
|
|
2280
2280
|
try {
|
|
2281
2281
|
const painter = await createNodePainter({ width, height, pixelRatio });
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
const
|
|
2285
|
-
|
|
2286
|
-
const
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2282
|
+
const CHUNK_SIZE = 30;
|
|
2283
|
+
for (let chunkStart = 0; chunkStart < totalFrames; chunkStart += CHUNK_SIZE) {
|
|
2284
|
+
const chunkEnd = Math.min(chunkStart + CHUNK_SIZE, totalFrames);
|
|
2285
|
+
const chunkSize = chunkEnd - chunkStart;
|
|
2286
|
+
const chunkOps = [];
|
|
2287
|
+
for (let frame = chunkStart; frame < chunkEnd; frame++) {
|
|
2288
|
+
const t = frame / (totalFrames - 1) * duration;
|
|
2289
|
+
chunkOps.push(await frameGenerator(t));
|
|
2290
|
+
}
|
|
2291
|
+
for (let i = 0; i < chunkSize; i++) {
|
|
2292
|
+
const frame = chunkStart + i;
|
|
2293
|
+
await painter.render(chunkOps[i]);
|
|
2294
|
+
const png = await painter.toPNG();
|
|
2295
|
+
const ok = ffmpeg.stdin.write(png);
|
|
2296
|
+
if (!ok) await new Promise((r) => ffmpeg.stdin.once("drain", r));
|
|
2297
|
+
if (frame % Math.max(1, Math.floor(fps / 2)) === 0) {
|
|
2298
|
+
const pct = Math.round((frame + 1) / totalFrames * 100);
|
|
2299
|
+
console.log(`\u{1F39E}\uFE0F Rendering frames: ${pct}%`);
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
chunkOps.length = 0;
|
|
2303
|
+
if (global.gc && chunkEnd < totalFrames) {
|
|
2304
|
+
global.gc();
|
|
2292
2305
|
}
|
|
2293
2306
|
}
|
|
2294
2307
|
ffmpeg.stdin.end();
|
package/package.json
CHANGED