From 888b142e2ef9a5e200e520bf14b63e8c97f39082 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 11 Mar 2024 15:40:14 +0100 Subject: [PATCH] Fix storyboard generation with some videos Where `t` variable is never an integer due to our setpts formula --- packages/ffmpeg/src/ffmpeg-images.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/ffmpeg/src/ffmpeg-images.ts b/packages/ffmpeg/src/ffmpeg-images.ts index 296cd10fb..52076de54 100644 --- a/packages/ffmpeg/src/ffmpeg-images.ts +++ b/packages/ffmpeg/src/ffmpeg-images.ts @@ -119,8 +119,10 @@ export class FFmpegImage { const command = this.commandWrapper.buildCommand(path) const filter = [ + // Fix "t" variable with some videos `setpts=N/round(FRAME_RATE)/TB`, - `select='not(mod(t,${options.sprites.duration}))'`, + // First frame or the time difference between the last and the current frame is enough for our sprite interval + `select='isnan(prev_selected_t)+gte(t-prev_selected_t,${options.sprites.duration})'`, `scale=${sprites.size.width}:${sprites.size.height}`, `tile=layout=${sprites.count.width}x${sprites.count.height}` ].join(',')