mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
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:
@@ -66,15 +66,15 @@ func (g *SpriteGenerator) generateSpriteImage(encoder *ffmpeg.Encoder) error {
|
|||||||
logger.Infof("[generator] generating sprite image for %s", g.Info.VideoFile.Path)
|
logger.Infof("[generator] generating sprite image for %s", g.Info.VideoFile.Path)
|
||||||
|
|
||||||
// Create `this.chunkCount` thumbnails in the tmp directory
|
// 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++ {
|
for i := 0; i < g.Info.ChunkCount; i++ {
|
||||||
time := i * stepSize
|
time := float64(i) * stepSize
|
||||||
num := fmt.Sprintf("%.3d", i)
|
num := fmt.Sprintf("%.3d", i)
|
||||||
filename := "thumbnail" + num + ".jpg"
|
filename := "thumbnail" + num + ".jpg"
|
||||||
|
|
||||||
options := ffmpeg.ScreenshotOptions{
|
options := ffmpeg.ScreenshotOptions{
|
||||||
OutputPath: instance.Paths.Generated.GetTmpPath(filename),
|
OutputPath: instance.Paths.Generated.GetTmpPath(filename),
|
||||||
Time: float64(time),
|
Time: time,
|
||||||
Width: 160,
|
Width: 160,
|
||||||
}
|
}
|
||||||
encoder.Screenshot(g.Info.VideoFile, options)
|
encoder.Screenshot(g.Info.VideoFile, options)
|
||||||
|
|||||||
Reference in New Issue
Block a user