-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvidpack.js
More file actions
49 lines (40 loc) · 1.56 KB
/
vidpack.js
File metadata and controls
49 lines (40 loc) · 1.56 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
// written by alec armbruster for sonar software, llc.
// all rights reserved by sonar software, llc.
var exec = require('child_process').exec;
var program = require('commander');
var Promise = require('bluebird');
function promiseFromChildProcess(child) {
return new Promise(function (resolve, reject) {
child.addListener("error", reject);
child.addListener("exit", resolve);
});
}
program
.version('0.0.1')
.arguments('<vid>')
.action(function (vid) {
vidLoc = vid;
});
program.parse(process.argv);
if (typeof vidLoc === 'undefined') {
console.error('no command given!');
process.exit(1);
}
console.log("awaiting conversion results...");
promiseFromChildProcess(exec('ffmpeg -i ' + vidLoc + '.mp4 -vcodec libvpx -crf 18 -b:v 0 -an ' + vidLoc + '.webm')).then(function (result) {
console.log("done - converted " + vidLoc + ".mp4 to .webm");
}, function (err) {
console.log('fail - file rejected: ' + err);
});
promiseFromChildProcess(exec('ffmpeg -i ' + vidLoc + '.mp4 -vcodec libvpx -vf scale=544:-2 -crf 18 -b:v 0 -an ' + vidLoc + '_small.webm')).then(function (result) {
console.log("done - converted " + vidLoc + ".mp4 to mobile .webm");
}, function (err) {
console.log('fail - file rejected: ' + err);
});
promiseFromChildProcess(exec('ffmpeg -i ' + vidLoc + '.mp4 -vf scale=544:-2 -crf 18 -b:v 0 -an ' + vidLoc + '_small.mp4')).then(function (result) {
console.log("done - converted " + vidLoc + ".mp4 to mobile .mp4");
console.log("done!");
}, function (err) {
console.log('fail - file rejected: ' + err);
});