New options --video-format, --video-quality and --video-bitrate

pull/143/head
Romain 5 years ago
parent 54f3e184cc
commit 2c2c518f4b

@ -90,6 +90,9 @@ Output options:
--thumb-size Pixel size of the square thumbnails [number] [default: 120]
--large-size Pixel height of the fullscreen photos [number] [default: 1000]
--photo-quality Quality of the resized/converted photos [number] [default: 90]
--video-quality Quality of the converted video (percent) [number] [default: 75]
--video-bitrate Bitrate of the converted videos (e.g. 120k) [string] [default: null]
--video-format Video output format [choices: "mp4", "webm"] [default: "mp4"]
--download-photos Target of the photo download links [choices: "large", "copy", "symlink", "link"] [default: "large"]
--download-videos Target of the video download links [choices: "large", "copy", "symlink", "link"] [default: "large"]
--download-link-prefix Path or URL prefix for linked downloads [string]
@ -115,7 +118,7 @@ Website options:
--title Website title [default: "Photo album"]
--footer Text or HTML footer [default: null]
--google-analytics Code for Google Analytics tracking [string]
--embed-exif Embed exif metadata for each image into the gallery page (enable to use exif plugin) [boolean] [default: false]
--embed-exif Embed the exif metadata for each image into the gallery page [boolean] [default: false]
Deprecated:
--original-photos Copy and allow download of full-size photos [boolean] [default: false]
@ -135,8 +138,6 @@ Options:
The optional JSON config should contain a single object with one key
per argument, not including the leading "--". For example:
{ "sort-albums-by": "start-date" }
```
<!-- END cli -->

@ -44,6 +44,24 @@ const OPTIONS = {
type: 'number',
'default': 90
},
'video-quality': {
group: 'Output options:',
description: 'Quality of the converted video (percent)',
type: 'number',
'default': 75
},
'video-bitrate': {
group: 'Output options:',
description: 'Bitrate of the converted videos (e.g. 120k)',
type: 'string',
'default': null
},
'video-format': {
group: 'Output options:',
description: 'Video output format',
choices: ['mp4', 'webm'],
'default': 'mp4'
},
'download-photos': {
group: 'Output options:',
description: 'Target of the photo download links',
@ -282,6 +300,9 @@ exports.get = (args) => {
thumbSize: opts['thumb-size'],
largeSize: opts['large-size'],
photoQuality: opts['photo-quality'],
videoQuality: opts['video-quality'],
videoBitrate: opts['video-bitrate'],
videoFormat: opts['video-format'],
downloadPhotos: opts['download-photos'],
downloadVideos: opts['download-videos'],
downloadLinkPrefix: opts['download-link-prefix'],

6
package-lock.json generated

@ -4611,9 +4611,9 @@
}
},
"thumbsup-downsize": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/thumbsup-downsize/-/thumbsup-downsize-2.1.1.tgz",
"integrity": "sha512-pKeprB4XCoGouchjVP6yxVJRIeDSLhzBk42Z57DtH9i4v56yMI3ODLqs2htoAa47WloKIj29G/ncQLkGVSlYxw==",
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/thumbsup-downsize/-/thumbsup-downsize-2.2.0.tgz",
"integrity": "sha512-4QbOeODtnoiA4mEQeWr5OEXmYG5rh38cjl7vGN4h+Y0N9ysy6gZgcuQHskF2oDg/SbjZ0nUMV6fU4dljIjqSLg==",
"requires": {
"async": "2.6.1",
"debug": "3.2.6",

@ -57,7 +57,7 @@
"resolve-pkg": "^1.0.0",
"slugify": "^1.3.4",
"through2": "^3.0.0",
"thumbsup-downsize": "^2.1.1",
"thumbsup-downsize": "^2.2.0",
"url-join": "^4.0.0",
"yargs": "^12.0.5",
"zen-observable": "^0.8.11"

@ -10,7 +10,7 @@ exports.paths = function (filepath, mediaType, opts) {
items.download = download(filepath, opts['downloadPhotos'], opts['downloadLinkPrefix'], items.large)
return items
} else if (mediaType === 'video') {
const items = videoOutput(filepath)
const items = videoOutput(filepath, opts['videoFormat'])
items.download = download(filepath, opts['downloadVideos'], opts['downloadLinkPrefix'], items.video)
return items
} else {
@ -36,7 +36,7 @@ function imageOutput (filepath) {
}
}
function videoOutput (filepath) {
function videoOutput (filepath, videoFormat) {
return {
thumbnail: {
path: 'media/thumbs/' + ext(filepath, 'jpg'),
@ -47,7 +47,7 @@ function videoOutput (filepath) {
rel: 'video:poster'
},
video: {
path: 'media/large/' + ext(filepath, 'mp4'),
path: 'media/large/' + ext(filepath, videoFormat),
rel: 'video:resized'
}
}

@ -21,6 +21,11 @@ exports.createMap = function (opts) {
watermark: watermark,
animated: true
})
const videoOpts = {
format: opts.videoFormat,
quality: opts.videoQuality,
bitrate: opts.videoBitrate
}
return {
'fs:copy': (task, done) => fs.copy(task.src, task.dest, done),
'fs:symlink': (task, done) => fs.symlink(task.src, task.dest, done),
@ -28,6 +33,6 @@ exports.createMap = function (opts) {
'photo:large': (task, done) => downsize.image(task.src, task.dest, large, done),
'video:thumbnail': (task, done) => downsize.still(task.src, task.dest, thumbnail, done),
'video:poster': (task, done) => downsize.still(task.src, task.dest, large, done),
'video:resized': (task, done) => downsize.video(task.src, task.dest, {}, done)
'video:resized': (task, done) => downsize.video(task.src, task.dest, videoOpts, done)
}
}

@ -94,7 +94,7 @@ describe('Output paths', function () {
})
it('generates a resized "web" video', function () {
const o = output.paths('holidays/seagull.mp4', 'video', {})
const o = output.paths('holidays/seagull.mp4', 'video', { videoFormat: 'mp4' })
should(o.video).eql({
path: 'media/large/holidays/seagull.mp4',
rel: 'video:resized'
@ -103,7 +103,8 @@ describe('Output paths', function () {
it('can point downloads to the large version', function () {
const o = output.paths('holidays/seagull.mp4', 'video', {
downloadVideos: 'large'
downloadVideos: 'large',
videoFormat: 'mp4'
})
should(o.download).eql({
path: 'media/large/holidays/seagull.mp4',

@ -115,8 +115,32 @@ describe('actions', () => {
action(ANY_TASK, err => {
should(err).eql(null)
const downsizeArgs = shouldCallDownsize(downsize.video)
// video-processing doesn't support any arguments yet
should(downsizeArgs).eql({})
should(downsizeArgs).eql({
format: undefined,
quality: undefined,
bitrate: undefined
})
testEnd()
})
})
it('can specify options for video:resized', testEnd => {
const map = actions.createMap({
// note: some options are mutuqlly exclusive
// but this is OK for testing the mapping
videoFormat: 'mp4',
videoQuality: 75,
videoBitrate: '1200k'
})
const action = map['video:resized']
action(ANY_TASK, err => {
should(err).eql(null)
const downsizeArgs = shouldCallDownsize(downsize.video)
should(downsizeArgs).eql({
format: 'mp4',
quality: 75,
bitrate: '1200k'
})
testEnd()
})
})

Loading…
Cancel
Save