-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchild.js
More file actions
27 lines (25 loc) · 681 Bytes
/
Copy pathchild.js
File metadata and controls
27 lines (25 loc) · 681 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { braillefy } = require('img2braille');
module.exports = function (
{ index, startFrame, endFrame, asciiWidth, asciiOpts },
callback
) {
// Process frames asyncronously via promises
const promises = [];
for (let i = startFrame; i <= endFrame; i++) {
promises.push(
braillefy(
`./video/frames/frame${(i + '').padStart(4, '0')}.jpeg`,
asciiWidth,
asciiOpts
)
);
}
Promise.all(promises)
.then((frames) => {
callback(
`worker #${index} finished (pid ${process.pid}). generated ${frames.length} frames (${startFrame}-${endFrame})`,
frames
);
})
.catch((err) => callback(err));
};