From 9c985ba939ee1f6b9f4c1d50d7d4debea36ae9e1 Mon Sep 17 00:00:00 2001 From: Romain Date: Sun, 24 May 2020 20:22:25 +0200 Subject: [PATCH] Fix video.still with seek=0 (defaulted to 1) --- lib/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index 86f5cbb..cd0bf43 100644 --- a/lib/index.js +++ b/lib/index.js @@ -72,9 +72,9 @@ exports.still = function (source, target, options, callback) { function extractFrame (source, target, options, callback) { getSeekPoint(source, options, (_, seekPoint) => { - const midpoint = ['-i', source, '-vframes', 1, '-ss', seekPoint, '-y', target] + const atseek = ['-i', source, '-vframes', 1, '-ss', seekPoint, '-y', target] const fallback = ['-i', source, '-vframes', 1, '-y', target] - ffmpeg.exec(midpoint, (err) => { + ffmpeg.exec(atseek, (err) => { if (fs.existsSync(target)) { callback(err) } else { @@ -85,8 +85,10 @@ function extractFrame (source, target, options, callback) { } function getSeekPoint (source, options, callback) { - if (options.seek !== -1) { - callback(null, options.seek || DEFAULT_STILL_SEEK_SECONDS) + if (typeof options.seek !== 'number') { + callback(null, DEFAULT_STILL_SEEK_SECONDS) + } else if (options.seek !== -1) { + callback(null, options.seek) } else { ffprobe.getDuration(source, (err, duration) => { const seconds = err ? 0 : duration