Optimize video thumbnail generation

Process images in worker threads
Reduce ffmpeg calls
This commit is contained in:
Chocobozzz
2023-10-19 14:18:22 +02:00
parent ea6c2b064f
commit 272a902b2a
19 changed files with 226 additions and 156 deletions

View File

@@ -1,3 +1,4 @@
import { FfprobeData } from 'fluent-ffmpeg'
import { FFmpegCommandWrapper, FFmpegCommandWrapperOptions } from './ffmpeg-command-wrapper.js'
import { getVideoStreamDuration } from './ffprobe.js'
@@ -38,10 +39,11 @@ export class FFmpegImage {
async generateThumbnailFromVideo (options: {
fromPath: string
output: string
ffprobe?: FfprobeData
}) {
const { fromPath, output } = options
const { fromPath, output, ffprobe } = options
let duration = await getVideoStreamDuration(fromPath)
let duration = await getVideoStreamDuration(fromPath, ffprobe)
if (isNaN(duration)) duration = 0
this.commandWrapper.buildCommand(fromPath)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -652,7 +652,7 @@ describe('Test video playlists', function () {
let video3: string
before(async function () {
this.timeout(60000)
this.timeout(120000)
groupUser1 = [ Object.assign({}, servers[0], { accessToken: userTokenServer1 }) ]
groupWithoutToken1 = [ Object.assign({}, servers[0], { accessToken: undefined }) ]