feat(core): new --video-stills flag controls when the frame is taken

pull/210/head
Romain 4 years ago
parent 60c3902edc
commit c407873266

@ -97,6 +97,18 @@ const OPTIONS = {
choices: ['mp4', 'webm'],
'default': 'mp4'
},
'video-stills': {
group: 'Output options:',
description: 'Where the video still frame is taken',
choices: ['seek', 'middle'],
'default': 'seek'
},
'video-stills-seek': {
group: 'Output options:',
description: 'Number of seconds where the still frame is taken',
type: 'number',
'default': 1
},
'photo-preview': {
group: 'Output options:',
description: 'How lightbox photos are generated',

49
package-lock.json generated

@ -3422,9 +3422,9 @@
"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A=="
},
"mocha": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-7.1.2.tgz",
"integrity": "sha512-o96kdRKMKI3E8U0bjnfqW4QMk12MwZ4mhdBTf+B5a1q9+aq2HRnj+3ZdJu0B/ZhJeK78MgYuv6L8d/rA5AeBJA==",
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-7.2.0.tgz",
"integrity": "sha512-O9CIypScywTVpNaRrCAgoUnJgozpIofjKUYmJhiCIJMiuYnLI6otcb1/kpW9/n/tJODHGZ7i8aLQoDVsMtOKQQ==",
"dev": true,
"requires": {
"ansi-colors": "3.2.3",
@ -3708,9 +3708,9 @@
}
},
"moment": {
"version": "2.25.3",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.25.3.tgz",
"integrity": "sha512-PuYv0PHxZvzc15Sp8ybUCoQ+xpyPWvjOuK72a5ovzp2LI32rJXOiIfyoFoYvG3s6EwwrdkMyWuRiEHSZRLJNdg=="
"version": "2.26.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.26.0.tgz",
"integrity": "sha512-oIixUO+OamkUkwjhAVE18rAMfRJNsNe/Stid/gwHSOfHrOtw9EhAY2AHvdKZ/k/MggcYELFCJz/Sn2pL8b8JMw=="
},
"ms": {
"version": "2.0.0",
@ -5477,22 +5477,46 @@
}
},
"thumbsup-downsize": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/thumbsup-downsize/-/thumbsup-downsize-2.3.1.tgz",
"integrity": "sha512-SEarrVhh1/2lFIDUwH28ZPsWBnyISKQcesfcIGY+HKBEavLH4g5eFRo3oCkK4uXSmWXjHqEIyPDOX8T1OZT1Fw==",
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/thumbsup-downsize/-/thumbsup-downsize-2.4.1.tgz",
"integrity": "sha512-MN0LrQFXwIDN50BAxvTlkBNW3s+pjkvhxqLa84lyPzqphlLF/KpnZ6GvpRDR8r/j+3Ej/bIXiLi4xH5nGJYEfg==",
"requires": {
"async": "^3.0.1",
"async": "^3.2.0",
"debug": "^4.1.1",
"gm": "^1.23.1",
"mkdirp": "^0.5.1",
"mkdirp": "^1.0.4",
"split": "^1.0.1",
"tmp": "^0.1.0"
"tmp": "^0.2.1"
},
"dependencies": {
"mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="
},
"rimraf": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
"requires": {
"glob": "^7.1.3"
}
},
"tmp": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz",
"integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==",
"requires": {
"rimraf": "^3.0.0"
}
}
}
},
"tmp": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.1.0.tgz",
"integrity": "sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw==",
"dev": true,
"requires": {
"rimraf": "^2.6.3"
},
@ -5501,6 +5525,7 @@
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
"integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
"dev": true,
"requires": {
"glob": "^7.1.3"
}

@ -53,12 +53,12 @@
"listr": "^0.14.3",
"lodash": "^4.17.15",
"micromatch": "^4.0.2",
"moment": "^2.25.3",
"moment": "^2.26.0",
"readdir-enhanced": "^2.2.4",
"resolve-pkg": "^2.0.0",
"slugify": "^1.4.0",
"through2": "^3.0.1",
"thumbsup-downsize": "^2.3.1",
"thumbsup-downsize": "^2.4.1",
"url-join": "^4.0.1",
"yargs": "^15.3.1",
"zen-observable": "^0.8.15"
@ -69,7 +69,7 @@
"injectmd": "^1.0.0",
"istanbul": "^0.4.5",
"markdown-toc": "^1.1.0",
"mocha": "^7.1.2",
"mocha": "^7.2.0",
"mock-fs": "^4.12.0",
"mock-spawn": "^0.2.6",
"require-all": "^3.0.0",

@ -13,17 +13,21 @@ exports.createMap = function (opts) {
file: opts.watermark,
position: opts.watermarkPosition
}
const seek = opts.videoStills === 'middle' ? -1 : opts.videoStillsSeek
const thumbnail = Object.assign({}, defaultOptions, {
height: thumbSize,
width: thumbSize
width: thumbSize,
seek: seek
})
const small = Object.assign({}, defaultOptions, {
height: smallSize
height: smallSize,
seek: seek
})
const large = Object.assign({}, defaultOptions, {
height: largeSize,
watermark: watermark,
animated: true
animated: true,
seek: seek
})
const videoOpts = {
format: opts.videoFormat,

@ -109,6 +109,28 @@ describe('actions', () => {
})
})
it('video:poster can seek to a given number of seconds', testEnd => {
const map = actions.createMap({ videoStills: 'seek', videoStillsSeek: 5 })
const action = map['video:poster']
action(ANY_TASK, err => {
should(err).eql(null)
const downsizeArgs = shouldCallDownsize(downsize.still)
should(downsizeArgs).property('seek', 5)
testEnd()
})
})
it('video:poster can seek to the middle', testEnd => {
const map = actions.createMap({ videoStills: 'middle' })
const action = map['video:poster']
action(ANY_TASK, err => {
should(err).eql(null)
const downsizeArgs = shouldCallDownsize(downsize.still)
should(downsizeArgs).property('seek', -1)
testEnd()
})
})
it('video:resized = creates a web-friendly video', testEnd => {
const map = actions.createMap({})
const action = map['video:resized']
@ -126,7 +148,7 @@ describe('actions', () => {
it('can specify options for video:resized', testEnd => {
const map = actions.createMap({
// note: some options are mutuqlly exclusive
// note: some options are mutually exclusive
// but this is OK for testing the mapping
videoFormat: 'mp4',
videoQuality: 75,

Loading…
Cancel
Save