-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·49 lines (45 loc) · 1.01 KB
/
index.js
File metadata and controls
executable file
·49 lines (45 loc) · 1.01 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
#! /usr/bin/env node
const ffmpeg = require('fluent-ffmpeg');
const infile = process.argv[2];
const output = process.argv[3];
const overlay = `${__dirname}/overlay.png`;
const usage = `
Usage
$ spectacles path/to/source.mp4 path/to/output.mp4
`;
if (!infile) {
console.log(usage);
process.exit();
} else if (!output) {
console.log('Please specify an output file.');
process.exit();
}
ffmpeg(infile)
.input(overlay)
.outputOptions(['-map 0:a'])
.applyAutoPadding(true)
.complexFilter(
[
'scale=-2:720[rescaled]',
{
filter: 'crop',
options: 'ih:ih:iw/4:0',
inputs: 'rescaled',
outputs: 'crop'
},
{
filter: 'overlay',
options: {
x: '(main_w-overlay_w)/2',
y: '(main_h-overlay_h)/2',
},
inputs: 'crop',
outputs: 'output',
},
],
'output'
)
.output(output)
.on('error', error => console.log('Error: ' + error.message))
.on('end', () => console.log('Success!'))
.run();