polotno-node 2.9.24 → 2.9.25
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/assets/index-K6bexdEY.js +281 -0
- package/dist/index.html +1 -1
- package/package.json +2 -2
- package/video-parallel.js +11 -8
- package/dist/assets/index-B_ojGXHf.js +0 -279
package/dist/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
}
|
|
9
9
|
</style>
|
|
10
10
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
11
|
-
<script type="module" crossorigin src="./assets/index-
|
|
11
|
+
<script type="module" crossorigin src="./assets/index-K6bexdEY.js"></script>
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polotno-node",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.25",
|
|
4
4
|
"description": "Polotno workflow from NodeJS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"gifencoder": "^2.0.1",
|
|
27
27
|
"pixelmatch": "^5.3.0",
|
|
28
28
|
"pngjs": "^7.0.0",
|
|
29
|
-
"polotno": "^2.
|
|
29
|
+
"polotno": "^2.8.3",
|
|
30
30
|
"react": "^18.3.1",
|
|
31
31
|
"react-dom": "^18.3.1",
|
|
32
32
|
"vite": "^5.2.11"
|
package/video-parallel.js
CHANGED
|
@@ -127,7 +127,7 @@ module.exports.jsonToVideo = async function jsonToVideo(
|
|
|
127
127
|
const timePerFrame = 1000 / fps;
|
|
128
128
|
|
|
129
129
|
// loop through the images and add each to the animation
|
|
130
|
-
const framesNumber = Math.floor((duration / 1000) * fps);
|
|
130
|
+
const framesNumber = Math.floor((duration / 1000) * fps) || 1;
|
|
131
131
|
const frames = Array.from(Array(framesNumber).keys());
|
|
132
132
|
|
|
133
133
|
// split frames into parallel chunks
|
|
@@ -237,12 +237,17 @@ module.exports.jsonToVideo = async function jsonToVideo(
|
|
|
237
237
|
const inputs = [];
|
|
238
238
|
let pageStartTime = 0;
|
|
239
239
|
for (const page of json.pages) {
|
|
240
|
+
const pageDuration = page.duration || 5000;
|
|
240
241
|
for (const el of page.children) {
|
|
241
242
|
if (el.type === 'video') {
|
|
242
|
-
const
|
|
243
|
+
const startTime = el.startTime || 0;
|
|
244
|
+
const endTime = el.endTime || 1;
|
|
245
|
+
const dur = el.duration || 5000;
|
|
246
|
+
const elStartTime = startTime * dur;
|
|
247
|
+
|
|
243
248
|
const elDuration = Math.min(
|
|
244
|
-
|
|
245
|
-
|
|
249
|
+
pageDuration,
|
|
250
|
+
dur * (endTime - startTime)
|
|
246
251
|
);
|
|
247
252
|
const elEndTime = elStartTime + elDuration;
|
|
248
253
|
inputs.push({
|
|
@@ -251,16 +256,15 @@ module.exports.jsonToVideo = async function jsonToVideo(
|
|
|
251
256
|
inputStartTime: elStartTime,
|
|
252
257
|
inputEndTime: elEndTime,
|
|
253
258
|
outputStartTime: pageStartTime,
|
|
254
|
-
outputEndTime: pageStartTime +
|
|
259
|
+
outputEndTime: pageStartTime + pageDuration,
|
|
255
260
|
});
|
|
256
261
|
}
|
|
257
262
|
}
|
|
258
|
-
pageStartTime +=
|
|
263
|
+
pageStartTime += pageDuration;
|
|
259
264
|
}
|
|
260
265
|
|
|
261
266
|
const format = attrs.out.split('.').pop() || 'mp4';
|
|
262
267
|
|
|
263
|
-
console.time('ffmpeg');
|
|
264
268
|
await new Promise((resolve, reject) => {
|
|
265
269
|
const ffmpegCmd = ffmpeg()
|
|
266
270
|
.input(`${tempFolder.name}/%d.jpeg`)
|
|
@@ -307,7 +311,6 @@ module.exports.jsonToVideo = async function jsonToVideo(
|
|
|
307
311
|
} catch (e) {
|
|
308
312
|
throw e;
|
|
309
313
|
} finally {
|
|
310
|
-
console.timeEnd('ffmpeg');
|
|
311
314
|
fs.rmSync(tempFolder.name, { recursive: true });
|
|
312
315
|
}
|
|
313
316
|
};
|