mirror of
https://github.com/stashapp/stash.git
synced 2026-05-09 05:05:29 +02:00
Adds a separate generationHardwareAcceleration config toggle that opts the preview, marker, transcode, and clip-thumbnail tasks into the existing HW pipeline. Generator methods take path/width/height primitives; the marker task only probes for HW when a video preview is actually requested. On NVENC: 8K/41min/15-marker scene goes from 8m to 5m; 1080p/9min with no markers 15s to 14s. Short 720p clips are slower. Reduce concurrent tasks if VRAM is limited.
62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
package manager
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/stashapp/stash/pkg/fsutil"
|
|
"github.com/stashapp/stash/pkg/image"
|
|
"github.com/stashapp/stash/pkg/logger"
|
|
"github.com/stashapp/stash/pkg/models"
|
|
)
|
|
|
|
type GenerateClipPreviewTask struct {
|
|
Image models.Image
|
|
Overwrite bool
|
|
}
|
|
|
|
func (t *GenerateClipPreviewTask) GetDescription() string {
|
|
return fmt.Sprintf("Generating Preview for image Clip %s", t.Image.Path)
|
|
}
|
|
|
|
func (t *GenerateClipPreviewTask) Start(ctx context.Context) {
|
|
if !t.required() {
|
|
return
|
|
}
|
|
|
|
prevPath := GetInstance().Paths.Generated.GetClipPreviewPath(t.Image.Checksum, models.DefaultGthumbWidth)
|
|
filePath := t.Image.Files.Primary().Base().Path
|
|
|
|
clipPreviewOptions := image.ClipPreviewOptions{
|
|
InputArgs: GetInstance().Config.GetTranscodeInputArgs(),
|
|
OutputArgs: GetInstance().Config.GetTranscodeOutputArgs(),
|
|
Preset: GetInstance().Config.GetPreviewPreset().String(),
|
|
HWAccel: GetInstance().Config.GetGenerationHardwareAcceleration(),
|
|
}
|
|
|
|
encoder := image.NewThumbnailEncoder(GetInstance().FFMpeg, GetInstance().FFProbe, clipPreviewOptions)
|
|
err := encoder.GetPreview(filePath, prevPath, models.DefaultGthumbWidth)
|
|
if err != nil {
|
|
logger.Errorf("getting preview for image %s: %w", filePath, err)
|
|
return
|
|
}
|
|
|
|
}
|
|
|
|
func (t *GenerateClipPreviewTask) required() bool {
|
|
_, ok := t.Image.Files.Primary().(*models.VideoFile)
|
|
if !ok {
|
|
return false
|
|
}
|
|
|
|
if t.Overwrite {
|
|
return true
|
|
}
|
|
|
|
prevPath := GetInstance().Paths.Generated.GetClipPreviewPath(t.Image.Checksum, models.DefaultGthumbWidth)
|
|
if exists, _ := fsutil.FileExists(prevPath); exists {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|