Generate single preview video for short scenes (#2553)

This commit is contained in:
WithoutPants
2022-05-04 09:28:48 +10:00
committed by GitHub
parent 20ffd4d51d
commit 21a26fadd8

View File

@@ -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 {
// #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 {
// a list of tmp files used during the preview generation
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 {
StartTime float64
Duration float64