mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Make audio stream optional for preview generation (#1454)
This commit is contained in:
@@ -12,6 +12,7 @@ type ScenePreviewChunkOptions struct {
|
||||
Duration float64
|
||||
Width int
|
||||
OutputPath string
|
||||
Audio bool
|
||||
}
|
||||
|
||||
func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePreviewChunkOptions, preset string, fallback bool) error {
|
||||
@@ -23,6 +24,17 @@ func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePre
|
||||
"-v", "error",
|
||||
}
|
||||
|
||||
argsAudio := []string{
|
||||
"-c:a", "aac",
|
||||
"-b:a", "128k",
|
||||
}
|
||||
|
||||
if !options.Audio {
|
||||
argsAudio = []string{
|
||||
"-an",
|
||||
}
|
||||
}
|
||||
|
||||
// Non-fallback: enable xerror.
|
||||
// "-xerror" causes ffmpeg to fail on warnings, often the preview is fine but could be broken.
|
||||
if !fallback {
|
||||
@@ -70,13 +82,12 @@ func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePre
|
||||
"-crf", "21",
|
||||
"-threads", "4",
|
||||
"-vf", fmt.Sprintf("scale=%v:-2", options.Width),
|
||||
"-c:a", "aac",
|
||||
"-b:a", "128k",
|
||||
"-strict", "-2",
|
||||
options.OutputPath,
|
||||
}
|
||||
|
||||
finalArgs := append(args, args2...)
|
||||
args3 := append(args, args2...)
|
||||
args3 = append(args3, argsAudio...)
|
||||
finalArgs := append(args3, options.OutputPath)
|
||||
|
||||
_, err := e.run(probeResult, finalArgs)
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user