-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (37 loc) · 1.11 KB
/
index.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const { isMainThread, parentPort, workerData } = require("worker_threads");
const captureframes = require("./worker");
const { handleError } = require("./lib");
(async function main() {
try {
if (isMainThread) {
const {
clgDonkeyLogo,
getProcessArguments,
prepareFramePartitions,
createFramesWithWorkers,
createVideo,
} = require("./lib");
clgDonkeyLogo();
// read process arguments
const { inputArguments, outputArguments } = await getProcessArguments();
// prepare milliseconds for frames in
// particions based on number of threads
const { framePartitions, totalFrames } = prepareFramePartitions(
inputArguments
);
// capture frame screenshots
const frames = await createFramesWithWorkers(
framePartitions,
totalFrames,
inputArguments
);
// creating the mp4 video
createVideo(frames, outputArguments);
} else {
const workerFrames = await captureframes(workerData);
parentPort.postMessage(workerFrames);
}
} catch (e) {
handleError(e);
}
})();