From 9a51c586dbc1a5bb20e1f7fcb0de604862a1625f Mon Sep 17 00:00:00 2001 From: Stash Dev Date: Tue, 31 Dec 2019 09:14:52 -0800 Subject: [PATCH] Fix incorrect sprites The step size was being cast to an int which made the time lose precision and would offset sprite images incorrectly --- pkg/manager/generator_sprite.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/manager/generator_sprite.go b/pkg/manager/generator_sprite.go index eb0d943b3..cc3b57f95 100644 --- a/pkg/manager/generator_sprite.go +++ b/pkg/manager/generator_sprite.go @@ -66,15 +66,15 @@ func (g *SpriteGenerator) generateSpriteImage(encoder *ffmpeg.Encoder) error { logger.Infof("[generator] generating sprite image for %s", g.Info.VideoFile.Path) // Create `this.chunkCount` thumbnails in the tmp directory - stepSize := int(g.Info.VideoFile.Duration / float64(g.Info.ChunkCount)) + stepSize := g.Info.VideoFile.Duration / float64(g.Info.ChunkCount) for i := 0; i < g.Info.ChunkCount; i++ { - time := i * stepSize + time := float64(i) * stepSize num := fmt.Sprintf("%.3d", i) filename := "thumbnail" + num + ".jpg" options := ffmpeg.ScreenshotOptions{ OutputPath: instance.Paths.Generated.GetTmpPath(filename), - Time: float64(time), + Time: time, Width: 160, } encoder.Screenshot(g.Info.VideoFile, options)