forked from vonhoro/Automate-encoding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautocrop.js
More file actions
78 lines (69 loc) · 2.2 KB
/
Copy pathautocrop.js
File metadata and controls
78 lines (69 loc) · 2.2 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const util = require("util");
const exec = util.promisify(require("child_process").exec);
const fs = require("fs");
const readline = require("readline");
const path = require("path");
const process = require("process");
const numberOfScreenhots = 10;
currentFolder = process.cwd();
let counter = 1;
// Modules
const { getVideoInfo } = require("./Modules/getVideoInfo.js");
const { createScreenshots } = require("./Modules/createScreenshots.js");
const { getOSuri, randomFrameDistribution } = require("./Modules/utils.js");
const {
cropVertically,
cropHorizontally,
} = require("./Modules/cropFunction.js");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.question(
"Put source video link \n Example:C:\\Users\\Admin\\Videos\\myvideo.mp4\n",
async (videoSrc) => {
const video = getOSuri(videoSrc);
await previewingScreenShots(video);
rl.close();
}
);
async function previewingScreenShots(video) {
try {
const { numberOfFrames } = await getVideoInfo(video);
const positions = randomFrameDistribution(
numberOfFrames,
numberOfScreenhots
);
await createScreenshots({
video,
jobId: "Crop preview",
folder: `Take number - ${counter}`,
test: "crop",
positions,
});
const folder = path.join(
currentFolder,
`jobCrop preview/Take number - ${counter}`
);
const { removeTop, removeBottom } = await cropVertically(folder, "crop");
const { removeRight, removeLeft } = await cropHorizontally(folder, "crop");
console.log(
`the recomended crop setting is\n clip = core.std.Crop(clip, left=${removeLeft}, right=${removeRight},top = ${removeTop},bottom = ${removeBottom})`
);
const extraOptions = `clip = core.std.Crop(clip, left=${removeLeft}, right=${removeRight},top = ${removeTop},bottom = ${removeBottom})`;
await createScreenshots({
video,
jobId: "Crop preview",
folder: `Take number - ${counter}`,
test: "Cropped",
positions,
extraOptions,
});
console.log(
`You can see all screenshots at jobCrop preview/Take number - ${counter} with the suggested options`
);
return;
} catch (err) {
console.log(err);
}
}