polotno-node 2.9.31 → 2.9.33
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 +10 -9
package/package.json
CHANGED
package/video-parallel.js
CHANGED
|
@@ -26,20 +26,21 @@ const convertToWebM = (input, output) => {
|
|
|
26
26
|
return new Promise((resolve, reject) => {
|
|
27
27
|
ffmpeg(input)
|
|
28
28
|
.outputOptions([
|
|
29
|
-
'-c:v libvpx',
|
|
29
|
+
'-c:v libvpx-vp9',
|
|
30
30
|
'-crf 30',
|
|
31
|
-
'-b:v
|
|
32
|
-
'-
|
|
33
|
-
'-
|
|
34
|
-
'-
|
|
31
|
+
'-b:v 0',
|
|
32
|
+
'-b:a 128k',
|
|
33
|
+
'-c:a libopus',
|
|
34
|
+
'-cpu-used 4', // Faster encoding with slight quality loss
|
|
35
|
+
'-deadline realtime', // Fastest encoding mode
|
|
36
|
+
'-threads 0', // Use all available CPU cores
|
|
35
37
|
])
|
|
36
38
|
.output(output)
|
|
37
|
-
.on('start', () => {})
|
|
38
39
|
.on('end', () => {
|
|
39
40
|
resolve();
|
|
40
41
|
})
|
|
41
42
|
.on('error', (err) => {
|
|
42
|
-
console.
|
|
43
|
+
console.error('Error occurred: ' + err.message);
|
|
43
44
|
reject(err);
|
|
44
45
|
})
|
|
45
46
|
.run();
|
|
@@ -62,12 +63,12 @@ const convertVideo = async (url, tempFolder) => {
|
|
|
62
63
|
const filename = Math.random().toString(36).substring(7);
|
|
63
64
|
const mp4Destination = path.join(tempFolder.name, filename + '.mp4');
|
|
64
65
|
await downloadVideo(url, mp4Destination);
|
|
65
|
-
console.log('Converting video to webm: ' +
|
|
66
|
+
console.log('Converting video to webm: ' + filename);
|
|
66
67
|
const webmDestination = mp4Destination.replace('.mp4', '.webm');
|
|
67
68
|
await convertToWebM(mp4Destination, webmDestination);
|
|
68
69
|
const dataURL = await fileToDataUrl(webmDestination);
|
|
69
70
|
|
|
70
|
-
console.log('Converting video finished: ' +
|
|
71
|
+
console.log('Converting video finished: ' + filename);
|
|
71
72
|
return {
|
|
72
73
|
dataURL,
|
|
73
74
|
file: webmDestination,
|