mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
Updated
On video thumbnails generation, skip video files that do not have any video streams/channels. This will prevent unnecessary spawning of ffmpeg for those files. Also suppress error logging when video streams/channels are not found.
This commit is contained in:
parent
e45d854c09
commit
f4fa6b6a96
@ -226,6 +226,11 @@ utilsController.generateThumbs = (name, force) => {
|
||||
// Otherwise video extension
|
||||
ffmpeg.ffprobe(input, (error, metadata) => {
|
||||
if (error) return reject(error)
|
||||
|
||||
// Skip files that do not have video streams/channels
|
||||
if (!metadata.streams || !metadata.streams.find(s => s.codec_type === 'video'))
|
||||
return reject(new Error('File does not contain any video stream'))
|
||||
|
||||
ffmpeg(input)
|
||||
.inputOptions([
|
||||
`-ss ${parseInt(metadata.format.duration) * 20 / 100}`
|
||||
@ -250,16 +255,20 @@ utilsController.generateThumbs = (name, force) => {
|
||||
})
|
||||
.then(resolve)
|
||||
.catch(error => {
|
||||
// Suppress error logging for errors these patterns
|
||||
const errorString = error.toString()
|
||||
const tests = [
|
||||
const suppress = [
|
||||
/Error: Input file contains unsupported image format/,
|
||||
/Error: ffprobe exited with code 1/
|
||||
/Error: ffprobe exited with code 1/,
|
||||
/Error: File does not contain any video stream/
|
||||
]
|
||||
if (!tests.some(t => t.test(errorString)))
|
||||
if (!suppress.some(t => t.test(errorString)))
|
||||
console.error(`${name}: ${errorString}`)
|
||||
|
||||
fs.symlink(thumbPlaceholder, thumbname, err => {
|
||||
if (err) console.error(err)
|
||||
// We return true if we could make a symlink to the placeholder image
|
||||
// We return true anyway
|
||||
// if we could make a symlink to the placeholder image
|
||||
resolve(!err)
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user