From de70b93cc627a73d4a828d29dbaaee29b3a20732 Mon Sep 17 00:00:00 2001 From: camjac251 Date: Fri, 29 May 2020 05:51:38 -0500 Subject: [PATCH 1/4] thumbnail generation fix and scale ffmpeg can sometimes generate broken thumbnails (sometimes a full grey image) when it seeks in the input instead of the output. When it's added after the input, it is a bit slower but it is more stable and will fixes the issue for various formats like HEVC or Prores. The resolution could benefit from being increased 3x for users who scale up the webpage in their browser or tablet views. It becomes scaled up 200% or 300% when viewed on a smaller screen. --- controllers/utilsController.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/utilsController.js b/controllers/utilsController.js index fb3fe9a..8cfa2a0 100644 --- a/controllers/utilsController.js +++ b/controllers/utilsController.js @@ -265,12 +265,12 @@ self.generateThumbs = async (name, extname, force) => { await new Promise((resolve, reject) => { ffmpeg(input) .inputOptions([ - `-ss ${duration * 20 / 100}` ]) .output(thumbname) .outputOptions([ + `-ss ${duration * 20 / 100}`, '-vframes 1', - '-vf scale=200:200:force_original_aspect_ratio=decrease' + '-vf scale=600:600:force_original_aspect_ratio=decrease' ]) .on('error', async error => { // Try to unlink thumbnail, From 776414814dd990914abe289c01f1f2a43709482a Mon Sep 17 00:00:00 2001 From: camjac251 Date: Mon, 1 Jun 2020 04:17:23 -0500 Subject: [PATCH 2/4] add user config option for thumbnail size --- config.sample.js | 3 ++- controllers/utilsController.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config.sample.js b/config.sample.js index f4c60c7..dd53e7e 100644 --- a/config.sample.js +++ b/config.sample.js @@ -418,7 +418,8 @@ module.exports = { generateThumbs: { image: true, video: false, - placeholder: null + placeholder: null, + size: 200 }, /* diff --git a/controllers/utilsController.js b/controllers/utilsController.js index 8cfa2a0..915e75f 100644 --- a/controllers/utilsController.js +++ b/controllers/utilsController.js @@ -222,8 +222,8 @@ self.generateThumbs = async (name, extname, force) => { // If image extension if (self.imageExts.includes(extname)) { const resizeOptions = { - width: 200, - height: 200, + width: ${config.uploads.generateThumbs.size}, + height: ${config.uploads.generateThumbs.size}, fit: 'contain', background: { r: 0, @@ -270,7 +270,7 @@ self.generateThumbs = async (name, extname, force) => { .outputOptions([ `-ss ${duration * 20 / 100}`, '-vframes 1', - '-vf scale=600:600:force_original_aspect_ratio=decrease' + `-vf scale=${config.uploads.generateThumbs.size}:${config.uploads.generateThumbs.size}:force_original_aspect_ratio=decrease` ]) .on('error', async error => { // Try to unlink thumbnail, From 9a4c0d5cea3d2b515f343b696efb4e32be3f0ed4 Mon Sep 17 00:00:00 2001 From: camjac251 Date: Mon, 1 Jun 2020 04:27:57 -0500 Subject: [PATCH 3/4] Update utilsController.js --- controllers/utilsController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/utilsController.js b/controllers/utilsController.js index 915e75f..458d60a 100644 --- a/controllers/utilsController.js +++ b/controllers/utilsController.js @@ -28,7 +28,7 @@ const self = { imageExts: ['.gif', '.jpeg', '.jpg', '.png', '.svg', '.tif', '.tiff', '.webp'], videoExts: ['.3g2', '.3gp', '.asf', '.avchd', '.avi', '.divx', '.evo', '.flv', '.h264', '.h265', '.hevc', '.m2p', '.m2ts', '.m4v', '.mk3d', '.mkv', '.mov', '.mp4', '.mpeg', '.mpg', '.mxf', '.ogg', '.ogv', '.ps', '.qt', '.rmvb', '.ts', '.vob', '.webm', '.wmv'], - + thumbSize: config.uploads.generateThumbs.size || 200, ffprobe: promisify(ffmpeg.ffprobe), albumsCache: {}, From cf2593465af785c4e37969e71724d00050e73ef2 Mon Sep 17 00:00:00 2001 From: camjac251 Date: Sat, 6 Jun 2020 02:39:53 -0500 Subject: [PATCH 4/4] Use top variable over config --- controllers/utilsController.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/controllers/utilsController.js b/controllers/utilsController.js index 458d60a..994d204 100644 --- a/controllers/utilsController.js +++ b/controllers/utilsController.js @@ -222,8 +222,8 @@ self.generateThumbs = async (name, extname, force) => { // If image extension if (self.imageExts.includes(extname)) { const resizeOptions = { - width: ${config.uploads.generateThumbs.size}, - height: ${config.uploads.generateThumbs.size}, + width: ${self.thumbSize}, + height: ${self.thumbSize}, fit: 'contain', background: { r: 0, @@ -270,7 +270,7 @@ self.generateThumbs = async (name, extname, force) => { .outputOptions([ `-ss ${duration * 20 / 100}`, '-vframes 1', - `-vf scale=${config.uploads.generateThumbs.size}:${config.uploads.generateThumbs.size}:force_original_aspect_ratio=decrease` + `-vf scale=${self.thumbSize}:${self.thumbSize}:force_original_aspect_ratio=decrease` ]) .on('error', async error => { // Try to unlink thumbnail,