Ported ffmpeg, ffprobe, exit and exec modules to typescript

This commit is contained in:
mmcwilliams 2019-06-08 20:51:00 -04:00
parent c169b7fbae
commit e3d213e4f1
44 changed files with 1857 additions and 351 deletions

View File

@ -1,7 +1,5 @@
'use strict'
const execRaw = require('child_process').exec
'use strict';
const execRaw = require('child_process').exec;
/**
* Promisified child_process.exec
*
@ -14,25 +12,25 @@ const execRaw = require('child_process').exec
* @returns {Promise<{ stdout: string, stderr: stderr }>}
*/
async function exec(...args) {
let cmd = args[0]
let argz = null
let opts = null
let cmd = args[0];
let argz = null;
let opts = null;
if (typeof args[1] === 'object' && Array.isArray(args[1])) {
argz = args[1]
argz = args[1];
}
if (argz === null && typeof args[1] === 'object') {
opts = args[1]
} else if (typeof args[2] === 'object') {
opts = args[2]
opts = args[1];
}
else if (typeof args[2] === 'object') {
opts = args[2];
}
if (opts === null) {
opts = { maxBuffer : 1024 * 1024 }
opts = { maxBuffer: 1024 * 1024 };
}
return new Promise((resolve, reject) => {
const child = execRaw(cmd, opts,
(err, stdout, stderr) => err ? reject(err) : resolve({
stdout: stdout,
stderr: stderr
const child = execRaw(cmd, opts, (err, stdout, stderr) => err ? reject(err) : resolve({
stdout,
stderr
}));
if (opts.stdout) {
child.stdout.pipe(opts.stdout);
@ -42,5 +40,5 @@ async function exec(...args) {
}
});
}
module.exports = exec
module.exports = exec;
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exec/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,IAAI,CAAA;AAE7C;;;;;;;;;;GAUG;AACH,KAAK,UAAU,IAAI,CAAC,GAAG,IAAe;IACrC,IAAI,GAAG,GAAY,IAAI,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,IAAI,GAAY,IAAI,CAAA;IACxB,IAAI,IAAI,GAAS,IAAI,CAAA;IAErB,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC1D,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;IACD,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACjD,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;SAAM,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACvC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;IACD,IAAI,IAAI,KAAK,IAAI,EAAE;QAClB,IAAI,GAAG,EAAE,SAAS,EAAG,IAAI,GAAG,IAAI,EAAE,CAAA;KAClC;IACE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,EACjC,CAAC,GAAW,EAAE,MAAe,EAAE,MAAc,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAC7E,MAAM;YACN,MAAM;SACN,CAAC,CAAC,CAAC;QACC,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA"}

View File

@ -1,5 +1,4 @@
'use strict';
/**
* Exit process with either a 0 code or other
* specified failure code. Print message to console first.
@ -7,15 +6,15 @@
* @param {string} msg Reason for exit
* @param {integer} code process exit code, default 0
**/
function exit(msg, code = 0) {
if (code === 0) {
console.log(msg);
process.exit();
} else {
}
else {
console.error(msg);
process.exit(code);
}
}
module.exports = exit;
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exit/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;IAMI;AAEJ,SAAS,IAAI,CAAE,GAAY,EAAE,OAAgB,CAAC;IAC7C,IAAI,IAAI,KAAK,CAAC,EAAE;QACf,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,EAAE,CAAC;KACf;SAAM;QACN,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACnB;AACF,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC"}

View File

@ -1,16 +1,17 @@
'use strict';
const uuid = require('uuid').v4;
const path = require('path');
const fs = require('fs-extra');
const exec = require('exec');
//const spawn = require('spawn');
const exit = require('exit');
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const path = __importStar(require("path"));
const fs = __importStar(require("fs-extra"));
const exec = __importStar(require("exec"));
let system = {};
let TMPDIR;
function padded_frame(i) {
let len = (i + '').length;
let str = i + '';
@ -19,77 +20,68 @@ function padded_frame (i) {
}
return str;
}
async function frame(state, light) {
let frame = state.frame
let video = state.path
let w = state.info.width
let h = state.info.height
let padded = padded_frame(frame)
let ext = 'tif'
let frame = state.frame;
let video = state.path;
let w = state.info.width;
let h = state.info.height;
let padded = padded_frame(frame);
let ext = 'tif';
let rgb = light.color;
let tmpoutput
let cmd
let output
let cmd2
let output2
let tmpoutput;
let cmd;
let output;
let cmd2;
let output2;
if (system.platform !== 'nix') {
ext = 'png'
ext = 'png';
}
rgb = rgb.map(e => {
rgb = rgb.map((e) => {
return parseInt(e);
});
tmpoutput = path.join(TMPDIR, `export-${padded}.${ext}`);
cmd = `ffmpeg -y -i "${video}" -vf "select='gte(n\\,${frame})',scale=${w}:${h}" -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"`;
cmd2 = `convert "${tmpoutput}" -resize ${w}x${h} -size ${w}x${h} xc:"rgb(${rgb[0]},${rgb[1]},${rgb[2]})" +swap -compose Darken -composite "${tmpoutput}"`;
//ffmpeg -i "${video}" -ss 00:00:07.000 -vframes 1 "export-${time}.jpg"
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "export-%05d.tiff"
//-vf "select=gte(n\,${frame})" -compression_algo raw -pix_fmt rgb24 "export-${padded}.png"
try {
console.log(cmd);
output = await exec(cmd);
} catch (err) {
}
catch (err) {
console.error(err);
}
if (output && output.stdout) console.log(`"${output.stdout}"`);
if (output && output.stdout)
console.log(`"${output.stdout}"`);
if (rgb[0] !== 255 || rgb[1] !== 255 || rgb[2] !== 255) {
try {
console.log(cmd2);
output2 = await exec(cmd2);
} catch (err) {
}
catch (err) {
console.error(err);
}
}
if (output2 && output2.stdout) console.log(`"${output2.stdout}"`);
if (output2 && output2.stdout)
console.log(`"${output2.stdout}"`);
}
async function frames(video, obj) {
let tmppath = TMPDIR;
let ext = 'tif';
let tmpoutput;
if (system.platform !== 'nix') {
ext = 'png';
}
tmpoutput = path.join(tmppath, `export-%05d.${ext}`);
try {
await fs.mkdir(tmppath)
} catch (Err) {
await fs.mkdir(tmppath);
}
catch (err) {
console.error(err);
}
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"
}
async function clear(frame) {
let padded = padded_frame(frame);
let ext = 'tif';
@ -97,83 +89,80 @@ async function clear (frame) {
let tmpoutput;
let cmd;
let exists;
if (system.platform !== 'nix') {
ext = 'png';
}
tmppath = path.join(TMPDIR, `export-${padded}.${ext}`);
try {
exists = await fs.exists(tmppath);
} catch (err) {
}
catch (err) {
console.error(err);
}
if (!exists) return false;
if (!exists)
return false;
try {
await fs.unlink(tmppath);
console.log(`Cleared frame ${tmppath}`);
} catch (err) {
}
catch (err) {
console.error(err);
}
return true;
}
async function clearAll() {
let tmppath = TMPDIR;
let files;
try {
files = await fs.readdir(tmppath);
} catch (err) {
}
catch (err) {
console.error(err);
}
if (files) {
files.forEach(async (file, index) => {
try {
await fs.unlink(path.join(tmppath, file));
} catch (err) {
}
catch (err) {
console.error(err);
}
});
}
}
async function checkDir() {
let exists;
try {
exists = await fs.exists(TMPDIR);
} catch (err) {
}
catch (err) {
console.error('Error checking for tmp dir', err);
}
if (!exists) {
try {
await fs.mkdir(TMPDIR);
console.log(`Created tmpdir ${TMPDIR}`);
} catch (err) {
}
catch (err) {
console.error('Error creating tmp dir', err);
}
}
try {
await clearAll();
} catch (err) {
}
catch (err) {
console.error(err);
}
}
module.exports = (sys) => {
system = sys;
TMPDIR = path.join(system.tmp, 'mcopy_digital');
checkDir();
return {
frames,
frame,
clear,
clearAll
}
}
};
};
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffmpeg/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;AAGb,2CAA6B;AAC7B,6CAA+B;AAC/B,2CAA6B;AAI7B,IAAI,MAAM,GAAS,EAAE,CAAC;AACtB,IAAI,MAAe,CAAC;AAEpB,SAAS,YAAY,CAAE,CAAU;IAChC,IAAI,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC;IAC1B,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QACjC,GAAG,GAAG,GAAG,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,IAAI;gBACH,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;aAC1C;YAAC,OAAO,GAAG,EAAE;gBACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACnB;QACF,CAAC,CAAC,CAAC;KACH;AACF,CAAC;AAED,KAAK,UAAU,QAAQ;IACtB,IAAI,MAAM,CAAC;IACX,IAAI;QACH,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KACjC;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;KACjD;IAED,IAAI,CAAC,MAAM,EAAE;QACZ,IAAI;YACH,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,EAAE,CAAC,CAAC;SACxC;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;SAC7C;KACD;IACD,IAAI;QACH,MAAM,QAAQ,EAAE,CAAC;KACjB;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;AACF,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,GAAS,EAAE,EAAE;IAC9B,MAAM,GAAG,GAAG,CAAC;IACb,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IAEhD,QAAQ,EAAE,CAAC;IAEX,OAAO;QACN,MAAM;QACN,KAAK;QACL,KAAK;QACL,QAAQ;KACR,CAAA;AACF,CAAC,CAAA"}

View File

@ -1,104 +1,103 @@
'use strict';
const fs = require('fs-extra');
const exec = require('exec');
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs-extra"));
const exec = __importStar(require("exec"));
//const spawn = require('spawn');
//const exit = require('exit');
let system = {};
async function info(video) {
let cmd = `ffprobe -v quiet -print_format json -show_format -show_streams "${video}"`
let cmd = `ffprobe -v quiet -print_format json -show_format -show_streams "${video}"`;
let exists;
let raw;
let json;
let vid;
try {
exists = await fs.exists(video);
} catch (err) {
}
catch (err) {
return exit(err, 5);
}
if (!exists) {
//return exit(`File ${video} does not exist`, 6);
console.error(err);
return false
console.error(new Error(`File ${video} does not exist`));
return false;
}
try {
console.log(cmd);
raw = await exec(cmd);
} catch (err) {
}
catch (err) {
//return exit(err, 7);
console.error(err);
return false
return false;
}
try {
json = JSON.parse(raw.stdout);
} catch (err) {
}
catch (err) {
return raw.stdout;
}
if (json && json.streams) {
vid = json.streams.find(stream => {
if (stream.width && stream.height) return stream;
vid = json.streams.find((stream) => {
if (stream.width && stream.height)
return stream;
});
}
if (vid) {
json.width = vid.width;
json.height = vid.height;
}
return json;
}
async function frames(video) {
let cmd = `ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 "${video}"`;
let exists;
let raw;
let frames;
try {
exists = await fs.exists(video);
} catch (err) {
}
catch (err) {
//return exit(err, 5);
console.error(err);
return false
return false;
}
if (!exists) {
//return exit(`File ${video} does not exist`, 6);
console.error(err);
console.error(new Error(`File ${video} does not exist`));
return false;
}
try {
console.log(cmd);
raw = await exec(cmd);
} catch (err) {
}
catch (err) {
console.error(err);
return false;
}
try {
frames = parseInt(raw.stdout)
} catch (err) {
frames = parseInt(raw.stdout);
}
catch (err) {
return raw.stdout;
}
return frames;
}
function map(obj) {
console.dir(obj);
}
module.exports = (sys) => {
system = sys;
return {
info,
frames
}
}
};
};
//# sourceMappingURL=index.js.map

View File

@ -0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C,GAAG,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,GAAS,EAAE,EAAE;IAC9B,MAAM,GAAG,GAAG,CAAC;IACb,OAAO;QACN,IAAI;QACJ,MAAM;KACN,CAAA;AACF,CAAC,CAAA"}

464
app/package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "mcopy-app",
"version": "1.4.7",
"version": "1.4.10",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -129,6 +129,30 @@
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"dev": true
},
"accepts": {
"version": "1.3.7",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
"integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
"requires": {
"mime-types": "~2.1.24",
"negotiator": "0.6.2"
},
"dependencies": {
"mime-db": {
"version": "1.40.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz",
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA=="
},
"mime-types": {
"version": "2.1.24",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz",
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
"requires": {
"mime-db": "1.40.0"
}
}
}
},
"accord": {
"version": "0.29.0",
"resolved": "https://registry.npmjs.org/accord/-/accord-0.29.0.tgz",
@ -226,7 +250,6 @@
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
"color-convert": "^1.9.0"
}
@ -409,6 +432,11 @@
"integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=",
"dev": true
},
"array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
},
"array-slice": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz",
@ -482,6 +510,11 @@
"lodash": "^4.17.11"
}
},
"async-limiter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
@ -581,6 +614,11 @@
"integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==",
"dev": true
},
"basic-auth-connect": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/basic-auth-connect/-/basic-auth-connect-1.0.0.tgz",
"integrity": "sha1-/bC0OWLKe0BFanwrtI/hc9otISI="
},
"bcrypt-pbkdf": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
@ -663,6 +701,43 @@
"bluebird": "^3.5.2"
}
},
"body-parser": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
"integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
"requires": {
"bytes": "3.1.0",
"content-type": "~1.0.4",
"debug": "2.6.9",
"depd": "~1.1.2",
"http-errors": "1.7.2",
"iconv-lite": "0.4.24",
"on-finished": "~2.3.0",
"qs": "6.7.0",
"raw-body": "2.4.0",
"type-is": "~1.6.17"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"qs": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
}
}
},
"bplist-creator": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.7.tgz",
@ -768,6 +843,11 @@
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
"dev": true
},
"bytes": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
"integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
},
"cache-base": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz",
@ -847,7 +927,6 @@
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
"dev": true,
"requires": {
"ansi-styles": "^3.2.1",
"escape-string-regexp": "^1.0.5",
@ -1149,6 +1228,19 @@
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4="
},
"content-disposition": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
"integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
"requires": {
"safe-buffer": "5.1.2"
}
},
"content-type": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
"integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
},
"convert-source-map": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz",
@ -1158,6 +1250,16 @@
"safe-buffer": "~5.1.1"
}
},
"cookie": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
"integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg=="
},
"cookie-signature": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
},
"copy-descriptor": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz",
@ -1413,12 +1515,22 @@
"resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz",
"integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o="
},
"depd": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
},
"deprecated": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz",
"integrity": "sha1-+cmvVGSvoeepcUWKi97yqpTVuxk=",
"dev": true
},
"destroy": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
},
"detect-file": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz",
@ -1485,6 +1597,11 @@
"safer-buffer": "^2.1.0"
}
},
"ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"electron": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/electron/-/electron-4.1.3.tgz",
@ -1854,6 +1971,11 @@
"env-variable": "0.0.x"
}
},
"encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
},
"end-of-stream": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
@ -1933,17 +2055,26 @@
"is-symbol": "^1.0.2"
}
},
"escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
},
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
},
"esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
},
"etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
},
"exec": {
"version": "file:lib/exec"
},
@ -2042,6 +2173,63 @@
"homedir-polyfill": "^1.0.1"
}
},
"express": {
"version": "4.17.1",
"resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
"integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
"requires": {
"accepts": "~1.3.7",
"array-flatten": "1.1.1",
"body-parser": "1.19.0",
"content-disposition": "0.5.3",
"content-type": "~1.0.4",
"cookie": "0.4.0",
"cookie-signature": "1.0.6",
"debug": "2.6.9",
"depd": "~1.1.2",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "~1.1.2",
"fresh": "0.5.2",
"merge-descriptors": "1.0.1",
"methods": "~1.1.2",
"on-finished": "~2.3.0",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.7",
"proxy-addr": "~2.0.5",
"qs": "6.7.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.1.2",
"send": "0.17.1",
"serve-static": "1.14.1",
"setprototypeof": "1.1.1",
"statuses": "~1.5.0",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"qs": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
}
}
},
"extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
@ -2242,6 +2430,35 @@
}
}
},
"finalhandler": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
"integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==",
"requires": {
"debug": "2.6.9",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"on-finished": "~2.3.0",
"parseurl": "~1.3.3",
"statuses": "~1.5.0",
"unpipe": "~1.0.0"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}
}
},
"find-index": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/find-index/-/find-index-0.1.1.tgz",
@ -2402,6 +2619,11 @@
"mime-types": "^2.1.12"
}
},
"forwarded": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
"integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
},
"fragment-cache": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz",
@ -2411,6 +2633,11 @@
"map-cache": "^0.2.2"
}
},
"fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
},
"fs-constants": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
@ -3391,8 +3618,7 @@
"has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
"dev": true
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0="
},
"has-gulplog": {
"version": "0.1.0",
@ -3467,6 +3693,18 @@
"integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==",
"dev": true
},
"http-errors": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
"integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
"requires": {
"depd": "~1.1.2",
"inherits": "2.0.3",
"setprototypeof": "1.1.1",
"statuses": ">= 1.5.0 < 2",
"toidentifier": "1.0.0"
}
},
"http-signature": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
@ -3482,6 +3720,14 @@
"resolved": "https://registry.npmjs.org/humanize-duration/-/humanize-duration-3.18.0.tgz",
"integrity": "sha512-reYy4EJMqlhX13TDlgSqLYfVGKOoixoEzsSL6DBlp22dScWN8Q2eMgDF4L0q28mzbgO40rnBy3WyEUQEhfYALw=="
},
"iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"requires": {
"safer-buffer": ">= 2.1.2 < 3"
}
},
"image-size": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz",
@ -3544,6 +3790,11 @@
"resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz",
"integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA=="
},
"ipaddr.js": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
"integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA=="
},
"is-absolute": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz",
@ -4267,6 +4518,11 @@
"object-visit": "^1.0.0"
}
},
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
},
"mem": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/mem/-/mem-4.0.0.tgz",
@ -4303,6 +4559,16 @@
}
}
},
"merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
"integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
},
"methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
},
"micromatch": {
"version": "3.1.10",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz",
@ -4327,9 +4593,7 @@
"mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"dev": true,
"optional": true
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
},
"mime-db": {
"version": "1.38.0",
@ -4643,6 +4907,11 @@
"integrity": "sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA==",
"dev": true
},
"negotiator": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
},
"nested-error-stacks": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/nested-error-stacks/-/nested-error-stacks-1.0.2.tgz",
@ -4723,6 +4992,27 @@
}
}
},
"node-media-server": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/node-media-server/-/node-media-server-2.1.0.tgz",
"integrity": "sha512-k5NTSTaHQceLTZLloEndNJ+lpiamiu+yR+2r+0yoZd6OEtsuA+udD03jdQ6ER+4jshjxxOqXDGv11Ew413MO3Q==",
"requires": {
"basic-auth-connect": "^1.0.0",
"chalk": "^2.4.2",
"dateformat": "^3.0.3",
"express": "^4.16.4",
"lodash": "^4.17.11",
"mkdirp": "^0.5.1",
"ws": "^5.2.2"
},
"dependencies": {
"dateformat": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz",
"integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q=="
}
}
},
"node-notifier": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.4.0.tgz",
@ -4940,6 +5230,14 @@
"isobject": "^3.0.1"
}
},
"on-finished": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
"integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
"requires": {
"ee-first": "1.1.1"
}
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
@ -5160,6 +5458,11 @@
"integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=",
"dev": true
},
"parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
},
"pascalcase": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz",
@ -5202,6 +5505,11 @@
"integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=",
"dev": true
},
"path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
},
"path-type": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz",
@ -5391,6 +5699,15 @@
"proj": {
"version": "file:lib/proj"
},
"proxy-addr": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz",
"integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==",
"requires": {
"forwarded": "~0.1.2",
"ipaddr.js": "1.9.0"
}
},
"prr": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz",
@ -5438,6 +5755,22 @@
"murmur-32": "^0.1.0"
}
},
"range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
},
"raw-body": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
"integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==",
"requires": {
"bytes": "3.1.0",
"http-errors": "1.7.2",
"iconv-lite": "0.4.24",
"unpipe": "1.0.0"
}
},
"rc": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",
@ -5721,6 +6054,43 @@
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
"integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg=="
},
"send": {
"version": "0.17.1",
"resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
"integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==",
"requires": {
"debug": "2.6.9",
"depd": "~1.1.2",
"destroy": "~1.0.4",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "0.5.2",
"http-errors": "~1.7.2",
"mime": "1.6.0",
"ms": "2.1.1",
"on-finished": "~2.3.0",
"range-parser": "~1.2.1",
"statuses": "~1.5.0"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
},
"dependencies": {
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}
}
}
}
},
"sequencer": {
"version": "file:lib/sequencer"
},
@ -5747,6 +6117,17 @@
"debug": "^4.1.0"
}
},
"serve-static": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
"integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==",
"requires": {
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "0.17.1"
}
},
"server": {
"version": "file:lib/server"
},
@ -5778,6 +6159,11 @@
}
}
},
"setprototypeof": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
"integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
},
"settings": {
"version": "file:lib/settings"
},
@ -6173,6 +6559,11 @@
}
}
},
"statuses": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
},
"stream-buffers": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/stream-buffers/-/stream-buffers-2.2.0.tgz",
@ -6267,7 +6658,6 @@
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"dev": true,
"requires": {
"has-flag": "^3.0.0"
}
@ -6474,6 +6864,11 @@
"repeat-string": "^1.6.1"
}
},
"toidentifier": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
"integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
},
"tough-cookie": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz",
@ -6535,6 +6930,30 @@
"integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==",
"dev": true
},
"type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"requires": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"dependencies": {
"mime-db": {
"version": "1.40.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz",
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA=="
},
"mime-types": {
"version": "2.1.24",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz",
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
"requires": {
"mime-db": "1.40.0"
}
}
}
},
"typedarray": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
@ -6655,6 +7074,11 @@
"dev": true,
"optional": true
},
"unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
},
"unset-value": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz",
@ -6738,6 +7162,11 @@
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
},
"uuid": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
@ -6762,6 +7191,11 @@
"spdx-expression-parse": "^3.0.0"
}
},
"vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
},
"verror": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
@ -7056,6 +7490,14 @@
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"ws": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz",
"integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==",
"requires": {
"async-limiter": "~1.0.0"
}
},
"xmlbuilder": {
"version": "9.0.7",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",

View File

@ -63,6 +63,7 @@
"log": "file:lib/log",
"moment": "^2.24.0",
"mscript": "file:lib/mscript",
"node-media-server": "^2.1.0",
"node-notifier": "^5.4.0",
"proj": "file:lib/proj",
"request": "^2.88.0",

View File

@ -1,7 +1,5 @@
'use strict'
const execRaw = require('child_process').exec
'use strict';
const execRaw = require('child_process').exec;
/**
* Promisified child_process.exec
*
@ -14,25 +12,25 @@ const execRaw = require('child_process').exec
* @returns {Promise<{ stdout: string, stderr: stderr }>}
*/
async function exec(...args) {
let cmd = args[0]
let argz = null
let opts = null
let cmd = args[0];
let argz = null;
let opts = null;
if (typeof args[1] === 'object' && Array.isArray(args[1])) {
argz = args[1]
argz = args[1];
}
if (argz === null && typeof args[1] === 'object') {
opts = args[1]
} else if (typeof args[2] === 'object') {
opts = args[2]
opts = args[1];
}
else if (typeof args[2] === 'object') {
opts = args[2];
}
if (opts === null) {
opts = { maxBuffer : 1024 * 1024 }
opts = { maxBuffer: 1024 * 1024 };
}
return new Promise((resolve, reject) => {
const child = execRaw(cmd, opts,
(err, stdout, stderr) => err ? reject(err) : resolve({
stdout: stdout,
stderr: stderr
const child = execRaw(cmd, opts, (err, stdout, stderr) => err ? reject(err) : resolve({
stdout,
stderr
}));
if (opts.stdout) {
child.stdout.pipe(opts.stdout);
@ -42,5 +40,5 @@ async function exec(...args) {
}
});
}
module.exports = exec
module.exports = exec;
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exec/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,IAAI,CAAA;AAE7C;;;;;;;;;;GAUG;AACH,KAAK,UAAU,IAAI,CAAC,GAAG,IAAe;IACrC,IAAI,GAAG,GAAY,IAAI,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,IAAI,GAAY,IAAI,CAAA;IACxB,IAAI,IAAI,GAAS,IAAI,CAAA;IAErB,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC1D,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;IACD,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACjD,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;SAAM,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACvC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;IACD,IAAI,IAAI,KAAK,IAAI,EAAE;QAClB,IAAI,GAAG,EAAE,SAAS,EAAG,IAAI,GAAG,IAAI,EAAE,CAAA;KAClC;IACE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,EACjC,CAAC,GAAW,EAAE,MAAe,EAAE,MAAc,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAC7E,MAAM;YACN,MAAM;SACN,CAAC,CAAC,CAAC;QACC,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA"}

View File

@ -0,0 +1,13 @@
<a name="exit"></a>
## exit(msg, code)
Exit process with either a 0 code or other
specified failure code. Print message to console first.
**Kind**: global function
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| msg | <code>string</code> | | Reason for exit |
| code | <code>integer</code> | <code>0</code> | process exit code, default 0 |

View File

@ -1,15 +1,20 @@
'use strict';
const log = require('log')({quiet : false})
/**
* Exit process with either a 0 code or other
* specified failure code. Print message to console first.
*
* @param {string} msg Reason for exit
* @param {integer} code process exit code, default 0
**/
function exit(msg, code = 0) {
if (code === 0) {
log.info(msg);
console.log(msg);
process.exit();
} else {
log.error(msg);
}
else {
console.error(msg);
process.exit(code);
}
}
module.exports = exit;
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exit/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;IAMI;AAEJ,SAAS,IAAI,CAAE,GAAY,EAAE,OAAgB,CAAC;IAC7C,IAAI,IAAI,KAAK,CAAC,EAAE;QACf,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,EAAE,CAAC;KACf;SAAM;QACN,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACnB;AACF,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC"}

0
cli/lib/ffmpeg/Readme.md Normal file
View File

168
cli/lib/ffmpeg/index.js Normal file
View File

@ -0,0 +1,168 @@
'use strict';
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const path = __importStar(require("path"));
const fs = __importStar(require("fs-extra"));
const exec = __importStar(require("exec"));
let system = {};
let TMPDIR;
function padded_frame(i) {
let len = (i + '').length;
let str = i + '';
for (let x = 0; x < 5 - len; x++) {
str = '0' + str;
}
return str;
}
async function frame(state, light) {
let frame = state.frame;
let video = state.path;
let w = state.info.width;
let h = state.info.height;
let padded = padded_frame(frame);
let ext = 'tif';
let rgb = light.color;
let tmpoutput;
let cmd;
let output;
let cmd2;
let output2;
if (system.platform !== 'nix') {
ext = 'png';
}
rgb = rgb.map((e) => {
return parseInt(e);
});
tmpoutput = path.join(TMPDIR, `export-${padded}.${ext}`);
cmd = `ffmpeg -y -i "${video}" -vf "select='gte(n\\,${frame})',scale=${w}:${h}" -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"`;
cmd2 = `convert "${tmpoutput}" -resize ${w}x${h} -size ${w}x${h} xc:"rgb(${rgb[0]},${rgb[1]},${rgb[2]})" +swap -compose Darken -composite "${tmpoutput}"`;
//ffmpeg -i "${video}" -ss 00:00:07.000 -vframes 1 "export-${time}.jpg"
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "export-%05d.tiff"
//-vf "select=gte(n\,${frame})" -compression_algo raw -pix_fmt rgb24 "export-${padded}.png"
try {
console.log(cmd);
output = await exec(cmd);
}
catch (err) {
console.error(err);
}
if (output && output.stdout)
console.log(`"${output.stdout}"`);
if (rgb[0] !== 255 || rgb[1] !== 255 || rgb[2] !== 255) {
try {
console.log(cmd2);
output2 = await exec(cmd2);
}
catch (err) {
console.error(err);
}
}
if (output2 && output2.stdout)
console.log(`"${output2.stdout}"`);
}
async function frames(video, obj) {
let tmppath = TMPDIR;
let ext = 'tif';
let tmpoutput;
if (system.platform !== 'nix') {
ext = 'png';
}
tmpoutput = path.join(tmppath, `export-%05d.${ext}`);
try {
await fs.mkdir(tmppath);
}
catch (err) {
console.error(err);
}
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"
}
async function clear(frame) {
let padded = padded_frame(frame);
let ext = 'tif';
let tmppath;
let tmpoutput;
let cmd;
let exists;
if (system.platform !== 'nix') {
ext = 'png';
}
tmppath = path.join(TMPDIR, `export-${padded}.${ext}`);
try {
exists = await fs.exists(tmppath);
}
catch (err) {
console.error(err);
}
if (!exists)
return false;
try {
await fs.unlink(tmppath);
console.log(`Cleared frame ${tmppath}`);
}
catch (err) {
console.error(err);
}
return true;
}
async function clearAll() {
let tmppath = TMPDIR;
let files;
try {
files = await fs.readdir(tmppath);
}
catch (err) {
console.error(err);
}
if (files) {
files.forEach(async (file, index) => {
try {
await fs.unlink(path.join(tmppath, file));
}
catch (err) {
console.error(err);
}
});
}
}
async function checkDir() {
let exists;
try {
exists = await fs.exists(TMPDIR);
}
catch (err) {
console.error('Error checking for tmp dir', err);
}
if (!exists) {
try {
await fs.mkdir(TMPDIR);
console.log(`Created tmpdir ${TMPDIR}`);
}
catch (err) {
console.error('Error creating tmp dir', err);
}
}
try {
await clearAll();
}
catch (err) {
console.error(err);
}
}
module.exports = (sys) => {
system = sys;
TMPDIR = path.join(system.tmp, 'mcopy_digital');
checkDir();
return {
frames,
frame,
clear,
clearAll
};
};
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","s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AE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;AACF,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,GAAS,EAAE,EAAE;IAC9B,MAAM,GAAG,GAAG,CAAC;IACb,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IAEhD,QAAQ,EAAE,CAAC;IAEX,OAAO;QACN,MAAM;QACN,KAAK;QACL,KAAK;QACL,QAAQ;KACR,CAAA;AACF,CAAC,CAAA"}

View File

@ -0,0 +1,11 @@
{
"name": "ffmpeg",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}

View File

103
cli/lib/ffprobe/index.js Normal file
View File

@ -0,0 +1,103 @@
'use strict';
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs-extra"));
const exec = __importStar(require("exec"));
//const spawn = require('spawn');
//const exit = require('exit');
let system = {};
async function info(video) {
let cmd = `ffprobe -v quiet -print_format json -show_format -show_streams "${video}"`;
let exists;
let raw;
let json;
let vid;
try {
exists = await fs.exists(video);
}
catch (err) {
return exit(err, 5);
}
if (!exists) {
//return exit(`File ${video} does not exist`, 6);
console.error(new Error(`File ${video} does not exist`));
return false;
}
try {
console.log(cmd);
raw = await exec(cmd);
}
catch (err) {
//return exit(err, 7);
console.error(err);
return false;
}
try {
json = JSON.parse(raw.stdout);
}
catch (err) {
return raw.stdout;
}
if (json && json.streams) {
vid = json.streams.find((stream) => {
if (stream.width && stream.height)
return stream;
});
}
if (vid) {
json.width = vid.width;
json.height = vid.height;
}
return json;
}
async function frames(video) {
let cmd = `ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 "${video}"`;
let exists;
let raw;
let frames;
try {
exists = await fs.exists(video);
}
catch (err) {
//return exit(err, 5);
console.error(err);
return false;
}
if (!exists) {
//return exit(`File ${video} does not exist`, 6);
console.error(new Error(`File ${video} does not exist`));
return false;
}
try {
console.log(cmd);
raw = await exec(cmd);
}
catch (err) {
console.error(err);
return false;
}
try {
frames = parseInt(raw.stdout);
}
catch (err) {
return raw.stdout;
}
return frames;
}
function map(obj) {
console.dir(obj);
}
module.exports = (sys) => {
system = sys;
return {
info,
frames
};
};
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffprobe/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;AAEb,6CAA+B;AAC/B,2CAA4B;AAC5B,iCAAiC;AACjC,+BAA+B;AAE/B,IAAI,MAAM,GAAG,EAAE,CAAC;AAEhB,KAAK,UAAU,IAAI,CAAE,KAAc;IAClC,IAAI,GAAG,GAAG,mEAAmE,KAAK,GAAG,CAAA;IACrF,IAAI,MAAM,CAAC;IACX,IAAI,GAAG,CAAC;IACR,IAAI,IAAI,CAAC;IACT,IAAI,GAAG,CAAC;IAER,IAAI;QACH,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;KAChC;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;KACpB;IACD,IAAI,CAAC,MAAM,EAAE;QACZ,iDAAiD;QACjD,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,KAAK,iBAAiB,CAAC,CAAC,CAAC;QACzD,OAAO,KAAK,CAAA;KACZ;IAED,IAAI;QACH,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;KACtB;IAAC,OAAO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C;QACjB,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;KACtB;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,KAAK,CAAC;KACb;IAED,IAAI;QACH,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;KAC7B;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,GAAG,CAAC,MAAM,CAAC;KAClB;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,GAAG,CAAE,GAAS;IACtB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,GAAS,EAAE,EAAE;IAC9B,MAAM,GAAG,GAAG,CAAC;IACb,OAAO;QACN,IAAI;QACJ,MAAM;KACN,CAAA;AACF,CAAC,CAAA"}

View File

@ -0,0 +1,11 @@
{
"name": "ffprobe",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}

15
lib/exec/Readme.md Normal file
View File

@ -0,0 +1,15 @@
<a name="exec"></a>
## exec(cmd, arg, opts) ⇒ <code>Promise.&lt;{stdout: string, stderr: stderr}&gt;</code>
Promisified child_process.exec
**Kind**: global function
| Param | Type | Description |
| --- | --- | --- |
| cmd | | |
| arg | | |
| opts | | See child_process.exec node docs |
| opts.stdout | <code>stream.Writable</code> | If defined, child process stdout will be piped to it. |
| opts.stderr | <code>stream.Writable</code> | If defined, child process stderr will be piped to it. |

44
lib/exec/index.js Normal file
View File

@ -0,0 +1,44 @@
'use strict';
const execRaw = require('child_process').exec;
/**
* Promisified child_process.exec
*
* @param cmd
* @param arg
* @param opts See child_process.exec node docs
* @param {stream.Writable} opts.stdout If defined, child process stdout will be piped to it.
* @param {stream.Writable} opts.stderr If defined, child process stderr will be piped to it.
*
* @returns {Promise<{ stdout: string, stderr: stderr }>}
*/
async function exec(...args) {
let cmd = args[0];
let argz = null;
let opts = null;
if (typeof args[1] === 'object' && Array.isArray(args[1])) {
argz = args[1];
}
if (argz === null && typeof args[1] === 'object') {
opts = args[1];
}
else if (typeof args[2] === 'object') {
opts = args[2];
}
if (opts === null) {
opts = { maxBuffer: 1024 * 1024 };
}
return new Promise((resolve, reject) => {
const child = execRaw(cmd, opts, (err, stdout, stderr) => err ? reject(err) : resolve({
stdout,
stderr
}));
if (opts.stdout) {
child.stdout.pipe(opts.stdout);
}
if (opts.stderr) {
child.stderr.pipe(opts.stderr);
}
});
}
module.exports = exec;
//# sourceMappingURL=index.js.map

1
lib/exec/index.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exec/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,IAAI,CAAA;AAE7C;;;;;;;;;;GAUG;AACH,KAAK,UAAU,IAAI,CAAC,GAAG,IAAe;IACrC,IAAI,GAAG,GAAY,IAAI,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,IAAI,GAAY,IAAI,CAAA;IACxB,IAAI,IAAI,GAAS,IAAI,CAAA;IAErB,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC1D,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;IACD,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACjD,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;SAAM,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACvC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;IACD,IAAI,IAAI,KAAK,IAAI,EAAE;QAClB,IAAI,GAAG,EAAE,SAAS,EAAG,IAAI,GAAG,IAAI,EAAE,CAAA;KAClC;IACE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,EACjC,CAAC,GAAW,EAAE,MAAe,EAAE,MAAc,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAC7E,MAAM;YACN,MAAM;SACN,CAAC,CAAC,CAAC;QACC,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA"}

11
lib/exec/package.json Normal file
View File

@ -0,0 +1,11 @@
{
"name": "exec",
"version": "1.0.0",
"description": "<a name=\"exec\"></a>",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}

13
lib/exit/Readme.md Normal file
View File

@ -0,0 +1,13 @@
<a name="exit"></a>
## exit(msg, code)
Exit process with either a 0 code or other
specified failure code. Print message to console first.
**Kind**: global function
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| msg | <code>string</code> | | Reason for exit |
| code | <code>integer</code> | <code>0</code> | process exit code, default 0 |

20
lib/exit/index.js Normal file
View File

@ -0,0 +1,20 @@
'use strict';
/**
* Exit process with either a 0 code or other
* specified failure code. Print message to console first.
*
* @param {string} msg Reason for exit
* @param {integer} code process exit code, default 0
**/
function exit(msg, code = 0) {
if (code === 0) {
console.log(msg);
process.exit();
}
else {
console.error(msg);
process.exit(code);
}
}
module.exports = exit;
//# sourceMappingURL=index.js.map

1
lib/exit/index.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exit/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;IAMI;AAEJ,SAAS,IAAI,CAAE,GAAY,EAAE,OAAgB,CAAC;IAC7C,IAAI,IAAI,KAAK,CAAC,EAAE;QACf,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,EAAE,CAAC;KACf;SAAM;QACN,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACnB;AACF,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC"}

11
lib/exit/package.json Normal file
View File

@ -0,0 +1,11 @@
{
"name": "exit",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}

0
lib/ffmpeg/Readme.md Normal file
View File

168
lib/ffmpeg/index.js Normal file
View File

@ -0,0 +1,168 @@
'use strict';
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const path = __importStar(require("path"));
const fs = __importStar(require("fs-extra"));
const exec = __importStar(require("exec"));
let system = {};
let TMPDIR;
function padded_frame(i) {
let len = (i + '').length;
let str = i + '';
for (let x = 0; x < 5 - len; x++) {
str = '0' + str;
}
return str;
}
async function frame(state, light) {
let frame = state.frame;
let video = state.path;
let w = state.info.width;
let h = state.info.height;
let padded = padded_frame(frame);
let ext = 'tif';
let rgb = light.color;
let tmpoutput;
let cmd;
let output;
let cmd2;
let output2;
if (system.platform !== 'nix') {
ext = 'png';
}
rgb = rgb.map((e) => {
return parseInt(e);
});
tmpoutput = path.join(TMPDIR, `export-${padded}.${ext}`);
cmd = `ffmpeg -y -i "${video}" -vf "select='gte(n\\,${frame})',scale=${w}:${h}" -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"`;
cmd2 = `convert "${tmpoutput}" -resize ${w}x${h} -size ${w}x${h} xc:"rgb(${rgb[0]},${rgb[1]},${rgb[2]})" +swap -compose Darken -composite "${tmpoutput}"`;
//ffmpeg -i "${video}" -ss 00:00:07.000 -vframes 1 "export-${time}.jpg"
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "export-%05d.tiff"
//-vf "select=gte(n\,${frame})" -compression_algo raw -pix_fmt rgb24 "export-${padded}.png"
try {
console.log(cmd);
output = await exec(cmd);
}
catch (err) {
console.error(err);
}
if (output && output.stdout)
console.log(`"${output.stdout}"`);
if (rgb[0] !== 255 || rgb[1] !== 255 || rgb[2] !== 255) {
try {
console.log(cmd2);
output2 = await exec(cmd2);
}
catch (err) {
console.error(err);
}
}
if (output2 && output2.stdout)
console.log(`"${output2.stdout}"`);
}
async function frames(video, obj) {
let tmppath = TMPDIR;
let ext = 'tif';
let tmpoutput;
if (system.platform !== 'nix') {
ext = 'png';
}
tmpoutput = path.join(tmppath, `export-%05d.${ext}`);
try {
await fs.mkdir(tmppath);
}
catch (err) {
console.error(err);
}
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"
}
async function clear(frame) {
let padded = padded_frame(frame);
let ext = 'tif';
let tmppath;
let tmpoutput;
let cmd;
let exists;
if (system.platform !== 'nix') {
ext = 'png';
}
tmppath = path.join(TMPDIR, `export-${padded}.${ext}`);
try {
exists = await fs.exists(tmppath);
}
catch (err) {
console.error(err);
}
if (!exists)
return false;
try {
await fs.unlink(tmppath);
console.log(`Cleared frame ${tmppath}`);
}
catch (err) {
console.error(err);
}
return true;
}
async function clearAll() {
let tmppath = TMPDIR;
let files;
try {
files = await fs.readdir(tmppath);
}
catch (err) {
console.error(err);
}
if (files) {
files.forEach(async (file, index) => {
try {
await fs.unlink(path.join(tmppath, file));
}
catch (err) {
console.error(err);
}
});
}
}
async function checkDir() {
let exists;
try {
exists = await fs.exists(TMPDIR);
}
catch (err) {
console.error('Error checking for tmp dir', err);
}
if (!exists) {
try {
await fs.mkdir(TMPDIR);
console.log(`Created tmpdir ${TMPDIR}`);
}
catch (err) {
console.error('Error creating tmp dir', err);
}
}
try {
await clearAll();
}
catch (err) {
console.error(err);
}
}
module.exports = (sys) => {
system = sys;
TMPDIR = path.join(system.tmp, 'mcopy_digital');
checkDir();
return {
frames,
frame,
clear,
clearAll
};
};
//# sourceMappingURL=index.js.map

1
lib/ffmpeg/index.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffmpeg/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;AAGb,2CAA6B;AAC7B,6CAA+B;AAC/B,2CAA6B;AAI7B,IAAI,MAAM,GAAS,EAAE,CAAC;AACtB,IAAI,MAAe,CAAC;AAEpB,SAAS,YAAY,CAAE,CAAU;IAChC,IAAI,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC;IAC1B,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QACjC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;KAChB;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,KAAK,UAAU,KAAK,CAAE,KAAW,EAAE,KAAW;IAC7C,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;IACvB,IAAI,KAAK,GAAG,KAAK,CAAC,IAAI,CAAA;IACtB,IAAI,CAAC,GAAG,KAAK,CAAC,IA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U,QAAQ;IACtB,IAAI,MAAM,CAAC;IACX,IAAI;QACH,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KACjC;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;KACjD;IAED,IAAI,CAAC,MAAM,EAAE;QACZ,IAAI;YACH,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,EAAE,CAAC,CAAC;SACxC;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;SAC7C;KACD;IACD,IAAI;QACH,MAAM,QAAQ,EAAE,CAAC;KACjB;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;AACF,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,GAAS,EAAE,EAAE;IAC9B,MAAM,GAAG,GAAG,CAAC;IACb,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IAEhD,QAAQ,EAAE,CAAC;IAEX,OAAO;QACN,MAAM;QACN,KAAK;QACL,KAAK;QACL,QAAQ;KACR,CAAA;AACF,CAAC,CAAA"}

11
lib/ffmpeg/package.json Normal file
View File

@ -0,0 +1,11 @@
{
"name": "ffmpeg",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}

0
lib/ffprobe/Readme.md Normal file
View File

103
lib/ffprobe/index.js Normal file
View File

@ -0,0 +1,103 @@
'use strict';
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs-extra"));
const exec = __importStar(require("exec"));
//const spawn = require('spawn');
//const exit = require('exit');
let system = {};
async function info(video) {
let cmd = `ffprobe -v quiet -print_format json -show_format -show_streams "${video}"`;
let exists;
let raw;
let json;
let vid;
try {
exists = await fs.exists(video);
}
catch (err) {
return exit(err, 5);
}
if (!exists) {
//return exit(`File ${video} does not exist`, 6);
console.error(new Error(`File ${video} does not exist`));
return false;
}
try {
console.log(cmd);
raw = await exec(cmd);
}
catch (err) {
//return exit(err, 7);
console.error(err);
return false;
}
try {
json = JSON.parse(raw.stdout);
}
catch (err) {
return raw.stdout;
}
if (json && json.streams) {
vid = json.streams.find((stream) => {
if (stream.width && stream.height)
return stream;
});
}
if (vid) {
json.width = vid.width;
json.height = vid.height;
}
return json;
}
async function frames(video) {
let cmd = `ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 "${video}"`;
let exists;
let raw;
let frames;
try {
exists = await fs.exists(video);
}
catch (err) {
//return exit(err, 5);
console.error(err);
return false;
}
if (!exists) {
//return exit(`File ${video} does not exist`, 6);
console.error(new Error(`File ${video} does not exist`));
return false;
}
try {
console.log(cmd);
raw = await exec(cmd);
}
catch (err) {
console.error(err);
return false;
}
try {
frames = parseInt(raw.stdout);
}
catch (err) {
return raw.stdout;
}
return frames;
}
function map(obj) {
console.dir(obj);
}
module.exports = (sys) => {
system = sys;
return {
info,
frames
};
};
//# sourceMappingURL=index.js.map

1
lib/ffprobe/index.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffprobe/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;AAEb,6CAA+B;AAC/B,2CAA4B;AAC5B,iCAAiC;AACjC,+BAA+B;AAE/B,IAAI,MAAM,GAAG,EAAE,CAAC;AAEhB,KAAK,UAAU,IAAI,CAAE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"ffprobe",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}

47
src/exec/index.ts Normal file
View File

@ -0,0 +1,47 @@
'use strict'
const execRaw = require('child_process').exec
/**
* Promisified child_process.exec
*
* @param cmd
* @param arg
* @param opts See child_process.exec node docs
* @param {stream.Writable} opts.stdout If defined, child process stdout will be piped to it.
* @param {stream.Writable} opts.stderr If defined, child process stderr will be piped to it.
*
* @returns {Promise<{ stdout: string, stderr: stderr }>}
*/
async function exec(...args : string[]) {
let cmd : string = args[0]
let argz : string = null
let opts : any = null
if (typeof args[1] === 'object' && Array.isArray(args[1])) {
argz = args[1]
}
if (argz === null && typeof args[1] === 'object') {
opts = args[1]
} else if (typeof args[2] === 'object') {
opts = args[2]
}
if (opts === null) {
opts = { maxBuffer : 1024 * 1024 }
}
return new Promise((resolve, reject) => {
const child = execRaw(cmd, opts,
(err : Error, stdout : string, stderr: string) => err ? reject(err) : resolve({
stdout,
stderr
}));
if (opts.stdout) {
child.stdout.pipe(opts.stdout);
}
if (opts.stderr) {
child.stderr.pipe(opts.stderr);
}
});
}
module.exports = exec

21
src/exit/index.ts Normal file
View File

@ -0,0 +1,21 @@
'use strict';
/**
* Exit process with either a 0 code or other
* specified failure code. Print message to console first.
*
* @param {string} msg Reason for exit
* @param {integer} code process exit code, default 0
**/
function exit (msg : string, code : number = 0) {
if (code === 0) {
console.log(msg);
process.exit();
} else {
console.error(msg);
process.exit(code);
}
}
module.exports = exit;

178
src/ffmpeg/index.ts Normal file
View File

@ -0,0 +1,178 @@
'use strict';
import uuid from 'uuid/v4';
import * as path from 'path';
import * as fs from 'fs-extra';
import * as exec from 'exec';
//const spawn = require('spawn');
import * as exit from 'exit';
let system : any = {};
let TMPDIR : string;
function padded_frame (i : number) {
let len = (i + '').length;
let str = i + '';
for (let x = 0; x < 5 - len; x++) {
str = '0' + str;
}
return str;
}
async function frame (state : any, light : any) {
let frame = state.frame
let video = state.path
let w = state.info.width
let h = state.info.height
let padded = padded_frame(frame)
let ext = 'tif'
let rgb = light.color;
let tmpoutput;
let cmd;
let output;
let cmd2;
let output2;
if (system.platform !== 'nix') {
ext = 'png';
}
rgb = rgb.map((e : string) => {
return parseInt(e);
});
tmpoutput = path.join(TMPDIR, `export-${padded}.${ext}`);
cmd = `ffmpeg -y -i "${video}" -vf "select='gte(n\\,${frame})',scale=${w}:${h}" -vframes 1 -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"`;
cmd2 = `convert "${tmpoutput}" -resize ${w}x${h} -size ${w}x${h} xc:"rgb(${rgb[0]},${rgb[1]},${rgb[2]})" +swap -compose Darken -composite "${tmpoutput}"`;
//ffmpeg -i "${video}" -ss 00:00:07.000 -vframes 1 "export-${time}.jpg"
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "export-%05d.tiff"
//-vf "select=gte(n\,${frame})" -compression_algo raw -pix_fmt rgb24 "export-${padded}.png"
try {
console.log(cmd);
output = await exec(cmd);
} catch (err) {
console.error(err);
}
if (output && output.stdout) console.log(`"${output.stdout}"`);
if (rgb[0] !== 255 || rgb[1] !== 255 || rgb[2] !== 255) {
try {
console.log(cmd2);
output2 = await exec(cmd2);
} catch (err) {
console.error(err);
}
}
if (output2 && output2.stdout) console.log(`"${output2.stdout}"`);
}
async function frames (video : string, obj : any) {
let tmppath = TMPDIR;
let ext = 'tif';
let tmpoutput;
if (system.platform !== 'nix') {
ext = 'png';
}
tmpoutput = path.join(tmppath, `export-%05d.${ext}`);
try {
await fs.mkdir(tmppath);
} catch (err) {
console.error(err);
}
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "${tmpoutput}"
}
async function clear (frame : number) {
let padded = padded_frame(frame);
let ext = 'tif';
let tmppath;
let tmpoutput;
let cmd;
let exists;
if (system.platform !== 'nix') {
ext = 'png';
}
tmppath = path.join(TMPDIR, `export-${padded}.${ext}`);
try {
exists = await fs.exists(tmppath);
} catch (err) {
console.error(err);
}
if (!exists) return false;
try {
await fs.unlink(tmppath);
console.log(`Cleared frame ${tmppath}`);
} catch (err) {
console.error(err);
}
return true;
}
async function clearAll () {
let tmppath = TMPDIR;
let files;
try {
files = await fs.readdir(tmppath);
} catch (err) {
console.error(err);
}
if (files) {
files.forEach(async (file : string, index : any) => {
try {
await fs.unlink(path.join(tmppath, file));
} catch (err) {
console.error(err);
}
});
}
}
async function checkDir () {
let exists;
try {
exists = await fs.exists(TMPDIR);
} catch (err) {
console.error('Error checking for tmp dir', err);
}
if (!exists) {
try {
await fs.mkdir(TMPDIR);
console.log(`Created tmpdir ${TMPDIR}`);
} catch (err) {
console.error('Error creating tmp dir', err);
}
}
try {
await clearAll();
} catch (err) {
console.error(err);
}
}
module.exports = (sys : any) => {
system = sys;
TMPDIR = path.join(system.tmp, 'mcopy_digital');
checkDir();
return {
frames,
frame,
clear,
clearAll
}
}

103
src/ffprobe/index.ts Normal file
View File

@ -0,0 +1,103 @@
'use strict';
import * as fs from 'fs-extra';
import * as exec from'exec';
//const spawn = require('spawn');
//const exit = require('exit');
let system = {};
async function info (video : string) {
let cmd = `ffprobe -v quiet -print_format json -show_format -show_streams "${video}"`
let exists;
let raw;
let json;
let vid;
try {
exists = await fs.exists(video);
} catch (err) {
return exit(err, 5);
}
if (!exists) {
//return exit(`File ${video} does not exist`, 6);
console.error(new Error(`File ${video} does not exist`));
return false
}
try {
console.log(cmd);
raw = await exec(cmd);
} catch (err) {
//return exit(err, 7);
console.error(err);
return false
}
try {
json = JSON.parse(raw.stdout);
} catch (err) {
return raw.stdout;
}
if (json && json.streams) {
vid = json.streams.find((stream : any) => {
if (stream.width && stream.height) return stream;
});
}
if (vid) {
json.width = vid.width;
json.height = vid.height;
}
return json;
}
async function frames (video : string) {
let cmd = `ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 "${video}"`;
let exists;
let raw;
let frames;
try {
exists = await fs.exists(video);
} catch (err) {
//return exit(err, 5);
console.error(err);
return false
}
if (!exists) {
//return exit(`File ${video} does not exist`, 6);
console.error(new Error(`File ${video} does not exist`));
return false;
}
try {
console.log(cmd);
raw = await exec(cmd);
} catch (err) {
console.error(err);
return false;
}
try {
frames = parseInt(raw.stdout)
} catch (err) {
return raw.stdout;
}
return frames;
}
function map (obj : any) {
console.dir(obj);
}
module.exports = (sys : any) => {
system = sys;
return {
info,
frames
}
}

1
src/globals.d.ts vendored
View File

@ -7,6 +7,7 @@ declare module 'uuid';
declare module 'exec';
declare module 'spawn';
declare module 'systeminformation';
declare module 'exit';
interface Device {
arduino : string;