polotno-node 2.9.12 → 2.9.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polotno-node",
3
- "version": "2.9.12",
3
+ "version": "2.9.13",
4
4
  "description": "Polotno workflow from NodeJS",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/video-parallel.js CHANGED
@@ -50,12 +50,14 @@ const fileToDataUrl = (filename) => {
50
50
  };
51
51
 
52
52
  const videoToDataURL = async (url, tempFolder) => {
53
+ console.log('Downloading video: ' + url.slice(0, 50) + '...');
53
54
  const filename = Math.random().toString(36).substring(7);
54
55
  const destination = path.join(tempFolder.name, filename + '.mp4');
55
56
  await downloadVideo(url, destination);
56
57
  const webmFile = destination.replace('.mp4', '.webm');
57
58
  await convertToWebM(destination, webmFile);
58
59
  const dataURL = await fileToDataUrl(webmFile);
60
+ console.log('Downloading video finished: ' + url.slice(0, 50) + '...');
59
61
  return {
60
62
  dataURL,
61
63
  file: webmFile,
@@ -70,10 +72,6 @@ const cachedVideoToDataURL = async (url, tempFolder) => {
70
72
  return urlCache[url];
71
73
  };
72
74
 
73
- function printProgress(progress) {
74
- console.log('Rendering frame: ' + progress + '%');
75
- }
76
-
77
75
  module.exports.jsonToVideo = async function jsonToVideo(inst, json, attrs) {
78
76
  const tempFolder = tmp.dirSync();
79
77
 
@@ -169,6 +167,7 @@ module.exports.jsonToVideo = async function jsonToVideo(inst, json, attrs) {
169
167
  }
170
168
  });
171
169
  }
170
+ const startTime = Date.now();
172
171
  const dataURL = await page.evaluate(
173
172
  async (json, attrs, currentTime) => {
174
173
  store.setCurrentTime(currentTime);
@@ -195,8 +194,9 @@ module.exports.jsonToVideo = async function jsonToVideo(inst, json, attrs) {
195
194
  );
196
195
  finishedFramesNumber += 1;
197
196
  if (attrs.onProgress) {
197
+ const frameTime = Date.now() - startTime;
198
198
  const progress = finishedFramesNumber / framesNumber;
199
- attrs.onProgress(progress);
199
+ attrs.onProgress(progress, frameTime);
200
200
  }
201
201
  }
202
202
  await page.close();