mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-19 01:31:34 +00:00
Updated utilsController.js
Thumbnails generator: Skip video files that does not have valid duration metadata, for some reason.
This commit is contained in:
parent
321e4557db
commit
2443390199
@ -248,15 +248,16 @@ self.generateThumbs = async (name, extname, force) => {
|
||||
}
|
||||
} else if (self.videoExts.includes(extname)) {
|
||||
const metadata = await self.ffprobe(input)
|
||||
const duration = parseInt(metadata.format.duration)
|
||||
|
||||
// Skip files that do not have video streams/channels
|
||||
if (!metadata.streams || !metadata.streams.some(s => s.codec_type === 'video'))
|
||||
throw 'File does not contain any video stream'
|
||||
// Skip files that have neither video streams/channels nor valid duration metadata
|
||||
if (!metadata.streams || !metadata.streams.some(s => s.codec_type === 'video') || isNaN(duration))
|
||||
throw 'File does not have valid required data'
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
ffmpeg(input)
|
||||
.inputOptions([
|
||||
`-ss ${parseInt(metadata.format.duration) * 20 / 100}`
|
||||
`-ss ${duration * 20 / 100}`
|
||||
])
|
||||
.output(thumbname)
|
||||
.outputOptions([
|
||||
@ -286,7 +287,7 @@ self.generateThumbs = async (name, extname, force) => {
|
||||
const suppress = [
|
||||
/Input file contains unsupported image format/,
|
||||
/Invalid data found when processing input/,
|
||||
/File does not contain any video stream/
|
||||
/File does not have valid required data/
|
||||
]
|
||||
|
||||
if (!suppress.some(t => t.test(errorString)))
|
||||
|
Loading…
Reference in New Issue
Block a user