Don't crash if ffprobe is missing
This commit is contained in:
parent
7bc247ede2
commit
88be0e1e92
|
@ -31,9 +31,12 @@ exports.query = function (filename, cb) {
|
|||
|
||||
ffprobe(filename, function (err, meta) {
|
||||
if (err) {
|
||||
if (meta.stderr && meta.stderr.match(/Protocol not found/)) {
|
||||
if (meta && meta.stderr && meta.stderr.match(/Protocol not found/)) {
|
||||
return cb("Link uses a protocol unsupported by this server's ffmpeg");
|
||||
} else if (err.code && err.code === "ENOENT") {
|
||||
return cb("Server is missing ffprobe");
|
||||
} else {
|
||||
Logger.errlog.log(err.stack || err);
|
||||
return cb("Unable to query file data with ffmpeg");
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +123,11 @@ function parse(meta) {
|
|||
}
|
||||
|
||||
function ffprobe(filename, cb) {
|
||||
var err;
|
||||
var ff = spawn("ffprobe", ["-show_streams", "-show_format", filename]);
|
||||
ff.on("error", function (err_) {
|
||||
err = err_;
|
||||
});
|
||||
|
||||
var outbuf = "";
|
||||
var errbuf = "";
|
||||
|
@ -133,7 +140,10 @@ function ffprobe(filename, cb) {
|
|||
|
||||
ff.on("close", function (code) {
|
||||
if (code !== 0) {
|
||||
return cb("ffprobe exited with nonzero exit code", { stderr: errbuf });
|
||||
if (!err) {
|
||||
err = "ffprobe exited with nonzero exit code";
|
||||
}
|
||||
return cb(err, { stderr: errbuf });
|
||||
}
|
||||
|
||||
var lines = outbuf.split("\n");
|
||||
|
|
Loading…
Reference in a new issue