From d8f39b126d9fe4bec1c12fb213548cc6edc87867 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 1 Jun 2023 14:51:16 +0200 Subject: Add storyboard support --- shared/ffmpeg/ffmpeg-images.ts | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'shared/ffmpeg') diff --git a/shared/ffmpeg/ffmpeg-images.ts b/shared/ffmpeg/ffmpeg-images.ts index 2db63bd8b..27305382c 100644 --- a/shared/ffmpeg/ffmpeg-images.ts +++ b/shared/ffmpeg/ffmpeg-images.ts @@ -56,4 +56,41 @@ export class FFmpegImage { .thumbnail(thumbnailOptions) }) } + + async generateStoryboardFromVideo (options: { + path: string + destination: string + + sprites: { + size: { + width: number + height: number + } + + count: { + width: number + height: number + } + + duration: number + } + }) { + const { path, destination, sprites } = options + + const command = this.commandWrapper.buildCommand(path) + + const filter = [ + `setpts=N/round(FRAME_RATE)/TB`, + `select='not(mod(t,${options.sprites.duration}))'`, + `scale=${sprites.size.width}:${sprites.size.height}`, + `tile=layout=${sprites.count.width}x${sprites.count.height}` + ].join(',') + + command.outputOption('-filter_complex', filter) + command.outputOption('-frames:v', '1') + command.outputOption('-q:v', '2') + command.output(destination) + + return this.commandWrapper.runCommand() + } } -- cgit v1.2.3