add env variables to rtsp

This commit is contained in:
Soph :3 2025-11-24 16:39:54 +02:00
parent f4a985a822
commit ae2a785dd7

View file

@ -15,6 +15,7 @@ import (
"path/filepath" "path/filepath"
"runtime" "runtime"
"runtime/pprof" "runtime/pprof"
"strconv"
"github.com/jonas-koeritz/actioncam/libipcamera" "github.com/jonas-koeritz/actioncam/libipcamera"
"github.com/jonas-koeritz/actioncam/rtsp" "github.com/jonas-koeritz/actioncam/rtsp"
@ -254,7 +255,24 @@ func main() {
Short: "Start an RTSP-Server serving the cameras preview.", Short: "Start an RTSP-Server serving the cameras preview.",
Args: cobra.MaximumNArgs(1), Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
rtspServer := rtsp.CreateServer(applicationContext, "127.0.0.1", 8554, camera) var port_string = os.Getenv("PORT");
if(port_string == "") {
port_string = "8554"
}
port, erra := strconv.Atoi(port_string);
if erra != nil {
log.Printf("ERROR: %s\n", erra)
return
}
var host = os.Getenv("HOST");
if(host == "") {
host = "127.0.0.1"
}
rtspServer := rtsp.CreateServer(applicationContext, host, port, camera)
defer rtspServer.Stop() defer rtspServer.Stop()
log.Printf("Created RTSP Server\n") log.Printf("Created RTSP Server\n")