From 429fc3869b99efe2489819d7757a7fc66484b617 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Thu, 17 Feb 2022 09:33:37 +1100 Subject: [PATCH] Clamp generator parameters (#2319) --- pkg/manager/generator.go | 9 +++++++++ .../src/components/Settings/GeneratePreviewOptions.tsx | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/manager/generator.go b/pkg/manager/generator.go index 68a186fa0..5a9a2a98a 100644 --- a/pkg/manager/generator.go +++ b/pkg/manager/generator.go @@ -114,6 +114,15 @@ func (g *GeneratorInfo) configure() error { return err } + // #2250 - ensure ChunkCount and ChunkDuration are valid + if g.ChunkCount < 1 { + logger.Warnf("[generator] Segment count (%d) must be > 0. Using 1 instead.", g.ChunkCount) + g.ChunkCount = 1 + } + if g.ChunkDuration < 0.75 { + logger.Warnf("[generator] Segment duration (%f) must be >= 0.75. Using 0.75 instead.", g.ChunkDuration) + g.ChunkDuration = 0.75 + } g.NthFrame = g.NumberOfFrames / g.ChunkCount return nil diff --git a/ui/v2.5/src/components/Settings/GeneratePreviewOptions.tsx b/ui/v2.5/src/components/Settings/GeneratePreviewOptions.tsx index 28aaf9153..bb4cba77d 100644 --- a/ui/v2.5/src/components/Settings/GeneratePreviewOptions.tsx +++ b/ui/v2.5/src/components/Settings/GeneratePreviewOptions.tsx @@ -47,11 +47,12 @@ export const VideoPreviewInput: React.FC = ({ ) => set({ previewSegments: Number.parseInt( - e.currentTarget.value || "0", + e.currentTarget.value || "1", 10 ), })