Support templates for FFmpeg raw param #487
This commit is contained in:
@@ -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",
|
"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
|
// 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
|
// if there is no another template - use input param as template
|
||||||
func inputTemplate(name, s string, query url.Values) string {
|
func inputTemplate(name, s string, query url.Values) string {
|
||||||
var template string
|
var template string
|
||||||
if input := query.Get("input"); input != "" {
|
if input := query.Get("input"); input != "" {
|
||||||
if template = defaults[input]; template == "" {
|
template = configTemplate(input)
|
||||||
template = input
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
template = defaults[name]
|
template = defaults[name]
|
||||||
}
|
}
|
||||||
@@ -191,6 +197,8 @@ func parseArgs(s string) *ffmpeg.Args {
|
|||||||
if query != nil {
|
if query != nil {
|
||||||
// 1. Process raw params for FFmpeg
|
// 1. Process raw params for FFmpeg
|
||||||
for _, raw := range query["raw"] {
|
for _, raw := range query["raw"] {
|
||||||
|
// support templates https://github.com/AlexxIT/go2rtc/issues/487
|
||||||
|
raw = configTemplate(raw)
|
||||||
args.AddCodec(raw)
|
args.AddCodec(raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user