From ae2a785dd73f6883bf6a5cc9226f87257a699b23 Mon Sep 17 00:00:00 2001 From: yourfriendoss Date: Mon, 24 Nov 2025 16:39:54 +0200 Subject: [PATCH] add env variables to `rtsp` --- actioncam.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/actioncam.go b/actioncam.go index 7c9e20f..df4a1d2 100644 --- a/actioncam.go +++ b/actioncam.go @@ -15,6 +15,7 @@ import ( "path/filepath" "runtime" "runtime/pprof" + "strconv" "github.com/jonas-koeritz/actioncam/libipcamera" "github.com/jonas-koeritz/actioncam/rtsp" @@ -254,7 +255,24 @@ func main() { Short: "Start an RTSP-Server serving the cameras preview.", Args: cobra.MaximumNArgs(1), 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() log.Printf("Created RTSP Server\n")