mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Generate single preview video for short scenes (#2553)
This commit is contained in:
@@ -91,6 +91,11 @@ func (g Generator) PreviewVideo(ctx context.Context, input string, videoDuration
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Generator) previewVideo(input string, videoDuration float64, options PreviewOptions, fallback bool) generateFn {
|
func (g *Generator) previewVideo(input string, videoDuration float64, options PreviewOptions, fallback bool) generateFn {
|
||||||
|
// #2496 - generate a single preview video for videos shorter than segments * segment duration
|
||||||
|
if videoDuration < options.SegmentDuration*float64(options.Segments) {
|
||||||
|
return g.previewVideoSingle(input, videoDuration, options, fallback)
|
||||||
|
}
|
||||||
|
|
||||||
return func(lockCtx *fsutil.LockContext, tmpFn string) error {
|
return func(lockCtx *fsutil.LockContext, tmpFn string) error {
|
||||||
// a list of tmp files used during the preview generation
|
// a list of tmp files used during the preview generation
|
||||||
var tmpFiles []string
|
var tmpFiles []string
|
||||||
@@ -145,6 +150,20 @@ func (g *Generator) previewVideo(input string, videoDuration float64, options Pr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Generator) previewVideoSingle(input string, videoDuration float64, options PreviewOptions, fallback bool) generateFn {
|
||||||
|
return func(lockCtx *fsutil.LockContext, tmpFn string) error {
|
||||||
|
chunkOptions := previewChunkOptions{
|
||||||
|
StartTime: 0,
|
||||||
|
Duration: videoDuration,
|
||||||
|
OutputPath: tmpFn,
|
||||||
|
Audio: options.Audio,
|
||||||
|
Preset: options.Preset,
|
||||||
|
}
|
||||||
|
|
||||||
|
return g.previewVideoChunk(lockCtx, input, chunkOptions, fallback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type previewChunkOptions struct {
|
type previewChunkOptions struct {
|
||||||
StartTime float64
|
StartTime float64
|
||||||
Duration float64
|
Duration float64
|
||||||
|
|||||||
Reference in New Issue
Block a user