Fix incorrect sprites

The step size was being cast to an int which made the time lose precision and would offset sprite images incorrectly
This commit is contained in:
Stash Dev 2019-12-31 09:14:52 -08:00
parent b31af52d41
commit 9a51c586db
1 changed files with 3 additions and 3 deletions

View File

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