diff --git a/lib/ffmpeg.js b/lib/ffmpeg.js index 2ed885e5..b2739fb7 100644 --- a/lib/ffmpeg.js +++ b/lib/ffmpeg.js @@ -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");