Skip to content

Commit

Permalink
Fix video.still with seek=0 (defaulted to 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
rprieto committed May 24, 2020
1 parent b8b7dfa commit 9c985ba
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 9c985ba

Please sign in to comment.