Updated utilsController.js

Thumbnails generator: Skip video files that does not have valid duration
metadata, for some reason.
This commit is contained in:
Bobby Wibowo 2019-10-15 17:53:23 +07:00
parent 321e4557db
commit 2443390199
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -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)))