mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-09 17:04:58 +02:00
Remove sharp in favor of ffmpeg, fallback to cover
This commit is contained in:
parent
9452d0eca9
commit
d6ae50f89a
5 changed files with 42 additions and 34 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue