Remove sharp in favor of ffmpeg, fallback to cover

This commit is contained in:
Keagan Hilliard 2021-12-13 11:29:31 -08:00
parent 9452d0eca9
commit d6ae50f89a
5 changed files with 42 additions and 34 deletions

View file

@ -92,4 +92,29 @@ async function extractCoverArt(filepath, outputpath) {
ffmpeg.run()
})
}
module.exports.extractCoverArt = extractCoverArt
module.exports.extractCoverArt = extractCoverArt
//This should convert based on the output file extension as well
async function resizeImage(filePath, outputPath, width, height) {
var dirname = Path.dirname(outputPath);
await fs.ensureDir(dirname);
return new Promise((resolve) => {
var ffmpeg = Ffmpeg(filePath)
ffmpeg.addOption(['-vf', `scale=${width || -1}:${height || -1}`])
ffmpeg.addOutput(outputPath)
ffmpeg.on('start', (cmd) => {
Logger.debug(`[FfmpegHelpers] Resize Image Cmd: ${cmd}`)
})
ffmpeg.on('error', (err, stdout, stderr) => {
Logger.error(`[FfmpegHelpers] Resize Image Error ${err}`)
resolve(false)
})
ffmpeg.on('end', () => {
Logger.debug(`[FfmpegHelpers] Image resized Successfully`)
resolve(outputPath)
})
ffmpeg.run()
})
}
module.exports.resizeImage = resizeImage