Skip to content

Commit

Permalink
fix: Reject promise on invalid seek (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipjscott committed Aug 14, 2019
1 parent 4161cf0 commit 1d4fe57
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
13 changes: 13 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down

0 comments on commit 1d4fe57

Please sign in to comment.