From 28c64d531a36a110a3069d71c51bba87a4b9a0fc Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Sat, 6 Jun 2020 19:28:42 +0700 Subject: [PATCH] Potentially much better video thumbnails Notable changes, use fluent-ffmpeg's functions instead of passing raw ffmpeg switches with inputOptions() or outputOptions(). It seems fluent-ffmpeg may be doing some janks with outputOptions(). I can't get select="eq(pict_type\\,I)" to work with it, but it works with videoFilters(). Weird stuff. --- controllers/utilsController.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/controllers/utilsController.js b/controllers/utilsController.js index 9aa1683..07acaf0 100644 --- a/controllers/utilsController.js +++ b/controllers/utilsController.js @@ -261,14 +261,19 @@ self.generateThumbs = async (name, extname, force) => { await new Promise((resolve, reject) => { ffmpeg(input) - .inputOptions([ - `-ss ${duration * 20 / 100}` + .seekInput(duration * 20 / 100) + .frames(1) + .videoFilters([ + { + filter: 'select', + options: 'eq(pict_type\\,I)' + }, + { + filter: 'scale', + options: '200:200:force_original_aspect_ratio=decrease' + } ]) .output(thumbname) - .outputOptions([ - '-vframes 1', - '-vf scale=200:200:force_original_aspect_ratio=decrease' - ]) .on('error', async error => { // Try to unlink thumbnail, // since ffmpeg may have created an incomplete thumbnail