Code refactoring for #1956
This commit is contained in:
@@ -2,7 +2,6 @@ package ffmpeg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/AlexxIT/go2rtc/internal/api"
|
"github.com/AlexxIT/go2rtc/internal/api"
|
||||||
@@ -59,15 +58,14 @@ func Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var defaults = map[string]string{
|
var defaults = map[string]string{
|
||||||
"bin": "ffmpeg",
|
"bin": "ffmpeg",
|
||||||
"global": "-hide_banner",
|
"global": "-hide_banner",
|
||||||
"timeout": "5",
|
"timeout": "5",
|
||||||
|
|
||||||
// inputs
|
// inputs
|
||||||
"file": "-re -i {input}",
|
"file": "-re -i {input}",
|
||||||
"http": "-fflags nobuffer -flags low_delay -i {input}",
|
"http": "-fflags nobuffer -flags low_delay -i {input}",
|
||||||
"rtsp": "-fflags nobuffer -flags low_delay -timeout {timeout} -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i {input}",
|
"rtsp": "-fflags nobuffer -flags low_delay -timeout {timeout} -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i {input}",
|
||||||
|
|
||||||
"rtsp/udp": "-fflags nobuffer -flags low_delay -timeout {timeout} -user_agent go2rtc/ffmpeg -i {input}",
|
"rtsp/udp": "-fflags nobuffer -flags low_delay -timeout {timeout} -user_agent go2rtc/ffmpeg -i {input}",
|
||||||
|
|
||||||
// output
|
// output
|
||||||
@@ -176,10 +174,7 @@ func inputTemplate(name, s string, query url.Values) string {
|
|||||||
if timeout == "" {
|
if timeout == "" {
|
||||||
timeout = defaults["timeout"]
|
timeout = defaults["timeout"]
|
||||||
}
|
}
|
||||||
if i, _ := strconv.Atoi(timeout); i > 0 {
|
template = strings.Replace(template, "{timeout}", timeout+"000000", 1)
|
||||||
timeout = strconv.Itoa(i * 1000000)
|
|
||||||
}
|
|
||||||
template = strings.Replace(template, "{timeout}", timeout, 1)
|
|
||||||
}
|
}
|
||||||
return strings.Replace(template, "{input}", s, 1)
|
return strings.Replace(template, "{input}", s, 1)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user