Potentially much better video thumbnails

Notable changes, use fluent-ffmpeg's functions instead of passing raw
ffmpeg switches with inputOptions() or outputOptions().

It seems fluent-ffmpeg may be doing some janks with outputOptions().
I can't get select="eq(pict_type\\,I)" to work with it, but it works
with videoFilters(). Weird stuff.
This commit is contained in:
Bobby Wibowo 2020-06-06 19:28:42 +07:00
parent 8b4b0e79c5
commit 28c64d531a
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -261,14 +261,19 @@ self.generateThumbs = async (name, extname, force) => {
await new Promise((resolve, reject) => {
ffmpeg(input)
.inputOptions([
`-ss ${duration * 20 / 100}`
.seekInput(duration * 20 / 100)
.frames(1)
.videoFilters([
{
filter: 'select',
options: 'eq(pict_type\\,I)'
},
{
filter: 'scale',
options: '200:200:force_original_aspect_ratio=decrease'
}
])
.output(thumbname)
.outputOptions([
'-vframes 1',
'-vf scale=200:200:force_original_aspect_ratio=decrease'
])
.on('error', async error => {
// Try to unlink thumbnail,
// since ffmpeg may have created an incomplete thumbnail