polotno-node 2.9.20 → 2.9.22
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 +1 -1
- package/video-parallel.js +13 -5
package/package.json
CHANGED
package/video-parallel.js
CHANGED
|
@@ -65,13 +65,13 @@ const videoToDataURL = async (url, tempFolder) => {
|
|
|
65
65
|
console.log('Converting video to webm: ' + mp4Destination);
|
|
66
66
|
const webmDestination = mp4Destination.replace('.mp4', '.webm');
|
|
67
67
|
await convertToWebM(mp4Destination, webmDestination);
|
|
68
|
-
fs.unlinkSync(mp4Destination);
|
|
69
68
|
const dataURL = await fileToDataUrl(webmDestination);
|
|
70
69
|
|
|
71
70
|
console.log('Converting video finished: ' + webmDestination);
|
|
72
71
|
return {
|
|
73
72
|
dataURL,
|
|
74
73
|
file: webmDestination,
|
|
74
|
+
mp4File: mp4Destination,
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
77
|
|
|
@@ -83,8 +83,14 @@ const cachedVideoToDataURL = async (url, tempFolder) => {
|
|
|
83
83
|
return urlCache[url];
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
-
module.exports.jsonToVideo = async function jsonToVideo(
|
|
87
|
-
|
|
86
|
+
module.exports.jsonToVideo = async function jsonToVideo(
|
|
87
|
+
inst,
|
|
88
|
+
json,
|
|
89
|
+
attrs = {}
|
|
90
|
+
) {
|
|
91
|
+
const tempFolder = tmp.dirSync({
|
|
92
|
+
tmpdir: attrs.tmpdir,
|
|
93
|
+
});
|
|
88
94
|
// const tempFolder = {
|
|
89
95
|
// name: './temp',
|
|
90
96
|
// };
|
|
@@ -102,12 +108,13 @@ module.exports.jsonToVideo = async function jsonToVideo(inst, json, attrs) {
|
|
|
102
108
|
|
|
103
109
|
await Promise.all(
|
|
104
110
|
videoEls.map(async (el) => {
|
|
105
|
-
const { dataURL, file } = await cachedVideoToDataURL(
|
|
111
|
+
const { dataURL, file, mp4File } = await cachedVideoToDataURL(
|
|
106
112
|
el.src,
|
|
107
113
|
tempFolder
|
|
108
114
|
);
|
|
109
115
|
el.src = dataURL;
|
|
110
116
|
el.file = file;
|
|
117
|
+
el.mp4File = mp4File;
|
|
111
118
|
})
|
|
112
119
|
);
|
|
113
120
|
|
|
@@ -240,6 +247,7 @@ module.exports.jsonToVideo = async function jsonToVideo(inst, json, attrs) {
|
|
|
240
247
|
const elEndTime = elStartTime + elDuration;
|
|
241
248
|
inputs.push({
|
|
242
249
|
file: el.file,
|
|
250
|
+
mp4File: el.mp4File,
|
|
243
251
|
inputStartTime: elStartTime,
|
|
244
252
|
inputEndTime: elEndTime,
|
|
245
253
|
outputStartTime: pageStartTime,
|
|
@@ -277,7 +285,7 @@ module.exports.jsonToVideo = async function jsonToVideo(inst, json, attrs) {
|
|
|
277
285
|
// Apply `-itsoffset` before each input file to shift its audio stream
|
|
278
286
|
ffmpegCmd
|
|
279
287
|
.inputOptions([`-itsoffset ${outputOffsetSec}`]) // Shift the input time
|
|
280
|
-
.input(input.
|
|
288
|
+
.input(input.mp4File) // Add the actual input file
|
|
281
289
|
.inputOptions([`-ss ${inputStartSec}`, `-t ${inputDurationSec}`]); // Specify the timing to cut the audio
|
|
282
290
|
});
|
|
283
291
|
|