mirror of
https://github.com/stashapp/stash.git
synced 2026-05-08 12:32:29 +02:00
refactor config default handling
This commit is contained in:
parent
8171b27095
commit
8830de78eb
2 changed files with 13 additions and 11 deletions
|
|
@ -84,7 +84,7 @@ const (
|
||||||
parallelTasksDefault = 1
|
parallelTasksDefault = 1
|
||||||
|
|
||||||
SpriteInterval = "sprite_interval"
|
SpriteInterval = "sprite_interval"
|
||||||
SpriteIntervalDefault = 0
|
SpriteIntervalDefault = 30
|
||||||
|
|
||||||
MinimumSprites = "minimum_sprites"
|
MinimumSprites = "minimum_sprites"
|
||||||
MinimumSpritesDefault = 10
|
MinimumSpritesDefault = 10
|
||||||
|
|
@ -982,12 +982,20 @@ func (i *Config) GetParallelTasksWithAutoDetection() int {
|
||||||
|
|
||||||
// GetSpriteInterval returns the time to be between each scrubber sprite
|
// GetSpriteInterval returns the time to be between each scrubber sprite
|
||||||
func (i *Config) GetSpriteInterval() int {
|
func (i *Config) GetSpriteInterval() int {
|
||||||
return i.getInt(SpriteInterval)
|
value := i.getInt(SpriteInterval)
|
||||||
|
if value <= 0 {
|
||||||
|
return SpriteIntervalDefault
|
||||||
|
}
|
||||||
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMinimumSprites return the minimum number of sprites that have to be generated
|
// GetMinimumSprites return the minimum number of sprites that have to be generated
|
||||||
func (i *Config) GetMinimumSprites() int {
|
func (i *Config) GetMinimumSprites() int {
|
||||||
return i.getInt(MinimumSprites)
|
value := i.getInt(MinimumSprites)
|
||||||
|
if value <= 0 {
|
||||||
|
return MinimumSpritesDefault
|
||||||
|
}
|
||||||
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Config) GetPreviewAudio() bool {
|
func (i *Config) GetPreviewAudio() bool {
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@ import (
|
||||||
"github.com/stashapp/stash/pkg/scene/generate"
|
"github.com/stashapp/stash/pkg/scene/generate"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
DefaultSpriteInterval = 30
|
|
||||||
)
|
|
||||||
|
|
||||||
type SpriteGenerator struct {
|
type SpriteGenerator struct {
|
||||||
Info *generatorInfo
|
Info *generatorInfo
|
||||||
|
|
||||||
|
|
@ -41,13 +37,11 @@ func NewSpriteGenerator(videoFile ffmpeg.VideoFile, videoChecksum string, imageO
|
||||||
}
|
}
|
||||||
slowSeek := false
|
slowSeek := false
|
||||||
|
|
||||||
spriteInterval := DefaultSpriteInterval
|
|
||||||
config := config.GetInstance()
|
config := config.GetInstance()
|
||||||
if config.GetSpriteInterval() != 0 {
|
|
||||||
spriteInterval = config.GetSpriteInterval()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
spriteInterval := config.GetSpriteInterval()
|
||||||
minimumSpriteCount := config.GetMinimumSprites()
|
minimumSpriteCount := config.GetMinimumSprites()
|
||||||
|
|
||||||
spriteCount := int64(math.Ceil(videoFile.VideoStreamDuration / float64(spriteInterval)))
|
spriteCount := int64(math.Ceil(videoFile.VideoStreamDuration / float64(spriteInterval)))
|
||||||
|
|
||||||
// For files with small duration / low frame count try to seek using frame number intead of seconds
|
// For files with small duration / low frame count try to seek using frame number intead of seconds
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue