From 187822421489ae811d118d15aa2d8361183250c2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 10 Jul 2020 14:54:11 +0200 Subject: Handle webp images from youtube-dl --- server/helpers/ffmpeg-utils.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'server/helpers/ffmpeg-utils.ts') diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index 557fb5e3a..0cfc51775 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts @@ -338,11 +338,29 @@ function getClosestFramerateStandard (fps: number, type: 'HD_STANDARD' | 'STANDA .sort((a, b) => fps % a - fps % b)[0] } +function convertWebPToJPG (path: string, destination: string): Promise { + return new Promise(async (res, rej) => { + try { + const command = ffmpeg(path).output(destination) + + command.on('error', (err, stdout, stderr) => { + logger.error('Error in ffmpeg webp convert process.', { stdout, stderr }) + return rej(err) + }) + .on('end', () => res()) + .run() + } catch (err) { + return rej(err) + } + }) +} + // --------------------------------------------------------------------------- export { getVideoStreamCodec, getAudioStreamCodec, + convertWebPToJPG, getVideoStreamSize, getVideoFileResolution, getMetadataFromFile, -- cgit v1.2.3