Handle webp images from youtube-dl

This commit is contained in:
Chocobozzz 2020-07-10 14:54:11 +02:00
parent 72493e44e9
commit 1878224214
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 34 additions and 5 deletions

View file

@ -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<void> {
return new Promise<void>(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,