-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (34 loc) · 1.14 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
#!/usr/bin/env node
const program = require('commander');
const pjson = require('./package.json');
const VideoCrop = require('video-crop').default;
function numList(val) {
return val.split(',').map(function(i) {
return parseInt(i);
});
}
program
.version(pjson.version)
.usage('[options] <inputFile> <outputFile>')
.option('-x, --xstart <xItems>', 'Comma separated x start point values for outputs', numList)
.option('-y, --ystart <yItems>', 'Comma separated y start point values for outputs', numList)
.option('-w, --width <widthItems>', 'Comma separated width values for outputs', numList)
.option('-h, --height <heightItems>', 'Comma separated height values for outputs', numList)
.option('-f, --fps <fps>', 'Frames Per Second on output video(s)')
.arguments('<inputFile> <outputFile>')
.action(function(inputFile, outputFile, cmd) {
const opts = {
input: inputFile,
output: outputFile,
x: cmd.xstart,
y: cmd.ystart,
width: cmd.width,
height: cmd.height
};
if(cmd.fps) {
opts.fps = cmd.fps;
}
const vc = new VideoCrop(opts);
vc.run();
});
program.parse(process.argv);