Clamp generator parameters (#2319)

This commit is contained in:
WithoutPants
2022-02-17 09:33:37 +11:00
committed by GitHub
parent 9321388770
commit 429fc3869b
2 changed files with 12 additions and 2 deletions

View File

@@ -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

View File

@@ -47,11 +47,12 @@ export const VideoPreviewInput: React.FC<IVideoPreviewInput> = ({
<Form.Control
className="text-input"
type="number"
value={previewSegments?.toString() ?? 0}
value={previewSegments?.toString() ?? 1}
min={1}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
set({
previewSegments: Number.parseInt(
e.currentTarget.value || "0",
e.currentTarget.value || "1",
10
),
})