Selectable wall preview type (#510)

* Add optional image preview generation
* Add setting for video preview encoding preset
This commit is contained in:
InfiniteTF
2020-05-27 01:33:49 +02:00
committed by GitHub
parent 197918d13c
commit 4ec6d62e01
18 changed files with 499 additions and 347 deletions

View File

@@ -13,9 +13,10 @@ type ScenePreviewChunkOptions struct {
OutputPath string
}
func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePreviewChunkOptions) {
func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePreviewChunkOptions, preset string) {
args := []string{
"-v", "error",
"-xerror",
"-ss", strconv.Itoa(options.Time),
"-i", probeResult.Path,
"-t", "0.75",
@@ -25,7 +26,7 @@ func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePre
"-pix_fmt", "yuv420p",
"-profile:v", "high",
"-level", "4.2",
"-preset", "slow",
"-preset", preset,
"-crf", "21",
"-threads", "4",
"-vf", fmt.Sprintf("scale=%v:-2", options.Width),

View File

@@ -11,6 +11,7 @@ import (
"strings"
"time"
"github.com/stashapp/stash/pkg/logger"
"github.com/stashapp/stash/pkg/manager/config"
)
@@ -264,7 +265,11 @@ func parse(filePath string, probeJSON *FFProbeJSON) (*VideoFile, error) {
result.Container = probeJSON.Format.FormatName
duration, _ := strconv.ParseFloat(probeJSON.Format.Duration, 64)
result.Duration = math.Round(duration*100) / 100
fileStat, _ := os.Stat(filePath)
fileStat, err := os.Stat(filePath)
if err != nil {
logger.Errorf("Error statting file: %v", err)
return nil, err
}
result.Size = fileStat.Size()
result.StartTime, _ = strconv.ParseFloat(probeJSON.Format.StartTime, 64)
result.CreationTime = probeJSON.Format.Tags.CreationTime.Time