avprobemeta
Version:
simple avprobe wrapper for node
35 lines (31 loc) • 760 B
JavaScript
var exec = require('child_process').exec;
var fs = require('fs');
var path = require('path');
module.exports = function(filePath, options, callback) {
var avprobe;
var cmd;
if (typeof options == "function") {
callback = options;
options = {};
}
if (options.format !== false) {
options.format = true;
}
if (options.streams !== false) {
options.streams = true;
}
cmd = [
options.cmdPath || 'avprobe',
options.streams ? '-show_streams' : '',
options.format ? '-show_format' : '',
'-of json',
filePath.replace(/([\s\(\)])/gi, '\\$1')
].join(' ');
avprobe = exec(cmd, function(err, stdout, stderr) {
if (err) {
callback(err);
return;
}
callback(null, JSON.parse(stdout));
});
}