diff --git a/index.js b/index.js index 9cdb4c0..59e3236 100644 --- a/index.js +++ b/index.js @@ -101,6 +101,10 @@ function ffmpegExecute (path, args, rstream, wstream) { const err = new Error(`ffmpeg exited ${code}\nffmpeg stderr:\n\n${stderr}`) reject(err) } + if (stderr.includes('nothing was encoded')) { + const err = new Error(`ffmpeg failed to encode file\nffmpeg stderr:\n\n${stderr}`) + reject(err) + } }) ffmpeg.on('close', resolve) }) diff --git a/test/test.js b/test/test.js index ea883c5..0982347 100644 --- a/test/test.js +++ b/test/test.js @@ -165,6 +165,19 @@ test('operates when ffmpeg path specified via env var', async t => { process.env.FFMPEG_PATH = '' }) +test('throws error when seek is outside range', async t => { + const input = absPath('./data/bunny.webm') + const output = absPath('./out/doesnotmatter.png') + + try { + await genThumbnail(input, output, '50x?', { seek: '00:05:00' }) + t.fail() + } catch (err) { + console.log(err) + t.pass() + } +}) + // Currently doesn't save in out folder since there's some weird race condition test('writes to a file via a write-stream', imageCreationMacro, { output: fs.createWriteStream(absPath('./write.png'))