diff --git a/lib/render.js b/lib/render.js index 8bc7df0..aa1df1b 100644 --- a/lib/render.js +++ b/lib/render.js @@ -1,4 +1,5 @@ var spawn = require('child_process').spawn +var fs = require('fs') //var Canvas = require('canvas') var defaultSetting = { @@ -32,6 +33,10 @@ function getPcmData (filename, options, sampleCallback, endCallback) { sampleRate = options.sampleRate } + if (!fs.existsSync(filename)) { + throw `File doesn't exist: ${filename}` + } + var ffmpeg = spawn('ffmpeg', ['-i', filename, '-f', 's16le', '-ac', channels, '-acodec', 'pcm_s16le', '-ar', sampleRate, '-y', 'pipe:1']) @@ -161,7 +166,7 @@ module.exports = function render (url, options, cb) { //canvasContext.fillStyle = options.baselineColor //canvasContext.fillRect(0, options.baseline - (options.baselineWidth / 2), options.width, options.baselineWidth) } - cb(null, canvas.toBuffer()) + //cb(null, canvas.toBuffer()) if (options.normalizedValuesCallback) { options.normalizedValuesCallback(normalizedVals);