RTSP Stream to WebBrowser over WebRTC based on Pion (full native! not using ffmpeg or gstreamer).
Note: This repository is a fork of RTSPtoWebRTC
The goal of this fork is to create a dynamic way of restreaming a rtsp connection to webrtc
go get github.com/salfel/RTSPtoWebRTC
Set config
rtsptowebrtc.SetConfig(&rtsptowebrtc.ConfigST{
Server: rtsptowebrtc.ServerST{
ICEServers: []string{"stun:stun.l.google.com:19302"},
},
})
Serve Routes (only gin for now)
r := gin.Default()
rtsptowebrtc.ServeGin(r)
Start Stream
rtsptowebrtc.ServeStream("test", rtsptowebrtc.StreamST{
OnDemand: false,
DisableAudio: true,
URL: "rtsp://127.0.0.1:8554/stream",
})
Remove Stream
rtsptowebrtc.RemoveStream("test")
Include both the webrtc-adapter.js and webrts.js scripts in your html markup
<script src="/js/webrtc-adapter.js"></script>
<script defer src="/js/webrtc.js"></script>
Be aware that you might need to change the suuid, depending on where in your url the suuid is located at or however you define it
You can also change the querySelector for the videoElement for more fine-grained control over the videoElement
A example application on how to integrate the RTSPtoWebRTC package can be found in this repository under the server dir