You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am new to Go and to RTSP and this library. Any help would be very much appreciated. I searched for Lorex and Describe and did not find any topics.
I am trying to read the stream from a Lorex camera that is Dahua based. According to Lorex documentation and the camera settings itself, the rtsp format is: rtsp://Username:Password@IP:Port/cam/realmonitor?channel=1&subtype=1
I have used this format in VLC (actually copied the rtspURL value from debug) and can get a stream, but when I try to connect in GO to rtsp I get an unsupported scheme error during client.Describe
The code is here:
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
// The main function starts the HTTP server and sets up the route for handling RTSP stream requests.
// The HTTP server listens on port 8080 on localhost and calls the handleStream function for any requests to the /stream endpoint.
func handleStream(w http.ResponseWriter, r *http.Request) {
// The handleStream function processes incoming HTTP requests to connect to an RTSP stream.
// It extracts the necessary parameters (user, pass, ip, port, channel, subtype) from the query string of the request.
// If any required parameters are missing, it responds with a 400 Bad Request error.
// If all parameters are present, it calls the connectRTSP function to establish a connection to the RTSP stream.
// If the connection is successful, it responds with a message indicating the RTSP URL that was connected to.
user := r.URL.Query().Get("user")
pass := r.URL.Query().Get("pass")
ip := r.URL.Query().Get("ip")
port := r.URL.Query().Get("port")
subtype := r.URL.Query().Get("subtype")
channel := r.URL.Query().Get("channel")
if user == "" || pass == "" || ip == "" || port == "" || channel == "" || subtype == "" {
fmt.Fprintf(os.Stderr, "Error: Missing required parameters\n")
http.Error(w, "Missing required parameters", http.StatusBadRequest)
return
}
client, rtspURL, err := connectRTSP(user, pass, ip, port, channel, subtype)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: Lorex Viewer Backend Failed to Connect to RTSP Stream: %v\n", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
defer client.Close()
fmt.Fprintf(w, "Connected to RTSP stream at %s", rtspURL)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am new to Go and to RTSP and this library. Any help would be very much appreciated. I searched for Lorex and Describe and did not find any topics.
I am trying to read the stream from a Lorex camera that is Dahua based. According to Lorex documentation and the camera settings itself, the rtsp format is: rtsp://Username:Password@IP:Port/cam/realmonitor?channel=1&subtype=1
I have used this format in VLC (actually copied the rtspURL value from debug) and can get a stream, but when I try to connect in GO to rtsp I get an unsupported scheme error during client.Describe
The code is here:
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
// The main function starts the HTTP server and sets up the route for handling RTSP stream requests.
// The HTTP server listens on port 8080 on localhost and calls the handleStream function for any requests to the /stream endpoint.
}
func handleStream(w http.ResponseWriter, r *http.Request) {
// The handleStream function processes incoming HTTP requests to connect to an RTSP stream.
// It extracts the necessary parameters (user, pass, ip, port, channel, subtype) from the query string of the request.
// If any required parameters are missing, it responds with a 400 Bad Request error.
// If all parameters are present, it calls the connectRTSP function to establish a connection to the RTSP stream.
// If the connection is successful, it responds with a message indicating the RTSP URL that was connected to.
}
package main
import (
"fmt"
"net/url"
"os"
)
func connectRTSP(user string, pass string, ip, port, channel string, subtype string) (*gortsplib.Client, string, error) {
// connectRTSP connects to the RTSP stream and returns the client and the RTSP URL used.
}
Beta Was this translation helpful? Give feedback.
All reactions