From c29dd8c4e38b55ad36c178cb7e813270c7003a22 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Mon, 3 Jul 2023 00:44:25 +0300 Subject: [PATCH] Support templates for FFmpeg raw param #487 --- internal/ffmpeg/ffmpeg.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/ffmpeg/ffmpeg.go b/internal/ffmpeg/ffmpeg.go index d185a5f6..8876283d 100644 --- a/internal/ffmpeg/ffmpeg.go +++ b/internal/ffmpeg/ffmpeg.go @@ -102,15 +102,21 @@ var defaults = map[string]string{ "h265/videotoolbox": "-c:v hevc_videotoolbox -g 50 -bf 0 -profile:v high -level:v 5.1", } +// configTemplate - return template from config (defaults) if exist or return raw template +func configTemplate(template string) string { + if s := defaults[template]; s != "" { + return s + } + return template +} + // inputTemplate - select input template from YAML config by template name -// if query has input param - select another tempalte by this name +// if query has input param - select another template by this name // if there is no another template - use input param as template func inputTemplate(name, s string, query url.Values) string { var template string if input := query.Get("input"); input != "" { - if template = defaults[input]; template == "" { - template = input - } + template = configTemplate(input) } else { template = defaults[name] } @@ -191,6 +197,8 @@ func parseArgs(s string) *ffmpeg.Args { if query != nil { // 1. Process raw params for FFmpeg for _, raw := range query["raw"] { + // support templates https://github.com/AlexxIT/go2rtc/issues/487 + raw = configTemplate(raw) args.AddCodec(raw) }