Make audio stream optional for preview generation (#1454)

This commit is contained in:
bnkai
2021-06-11 08:01:32 +03:00
committed by GitHub
parent f843359ba3
commit f1786ad871
11 changed files with 59 additions and 7 deletions

View File

@@ -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