mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-07 17:21:34 +08:00
Support stream name as ffmpeg input
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/AlexxIT/go2rtc/cmd/app"
|
"github.com/AlexxIT/go2rtc/cmd/app"
|
||||||
"github.com/AlexxIT/go2rtc/cmd/exec"
|
"github.com/AlexxIT/go2rtc/cmd/exec"
|
||||||
"github.com/AlexxIT/go2rtc/cmd/ffmpeg/device"
|
"github.com/AlexxIT/go2rtc/cmd/ffmpeg/device"
|
||||||
|
"github.com/AlexxIT/go2rtc/cmd/rtsp"
|
||||||
"github.com/AlexxIT/go2rtc/cmd/streams"
|
"github.com/AlexxIT/go2rtc/cmd/streams"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/streamer"
|
"github.com/AlexxIT/go2rtc/pkg/streamer"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -75,7 +76,7 @@ func Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var input string
|
var input string
|
||||||
if i := strings.IndexByte(s, ':'); i > 0 {
|
if i := strings.Index(s, "://"); i > 0 {
|
||||||
switch s[:i] {
|
switch s[:i] {
|
||||||
case "http", "https", "rtmp":
|
case "http", "https", "rtmp":
|
||||||
input = strings.Replace(tpl["http"], "{input}", s, 1)
|
input = strings.Replace(tpl["http"], "{input}", s, 1)
|
||||||
@@ -92,19 +93,26 @@ func Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
input += strings.Replace(tpl["rtsp"], "{input}", s, 1)
|
input += strings.Replace(tpl["rtsp"], "{input}", s, 1)
|
||||||
|
default:
|
||||||
|
input = "-i " + s
|
||||||
}
|
}
|
||||||
}
|
} else if streams.Get(s) != nil {
|
||||||
|
s = "rtsp://localhost:" + rtsp.Port + "/" + s
|
||||||
if input == "" {
|
switch {
|
||||||
if strings.HasPrefix(s, "device?") {
|
case queryVideo && !queryAudio:
|
||||||
var err error
|
s += "?video"
|
||||||
input, err = device.GetInput(s)
|
case queryAudio && !queryVideo:
|
||||||
if err != nil {
|
s += "?audio"
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
input = strings.Replace(tpl["file"], "{input}", s, 1)
|
|
||||||
}
|
}
|
||||||
|
input = strings.Replace(tpl["rtsp"], "{input}", s, 1)
|
||||||
|
} else if strings.HasPrefix(s, "device?") {
|
||||||
|
var err error
|
||||||
|
input, err = device.GetInput(s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
input = strings.Replace(tpl["file"], "{input}", s, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
s = cmd + input
|
s = cmd + input
|
||||||
|
Reference in New Issue
Block a user