开源项目:https://github.com/deepch/RTSPtoWebRTC
基本原理:
通过浏览器和RTSPtoWebRTC交换sdp信息,然后读取rtp包或者发送rtp的方式进行
<script> var video = document.getElementById('video-webrtc'); var url = 'webrtc://127.0.0.1:8083/stream/1'; var player = new JSWebrtc.Player(url, { video: video, autoplay: true, onPlay: (obj) => { console.log("start play") } }); //player.stop(); </script>
let jswebrtc = _self.urlParams.url; var ip = jswebrtc.split(":")[1]; var param = jswebrtc.split(":")[2]; var port = param.split("/")[0]; var streampath = param.replaceAll(port + "/", ""); var streamid = streampath.replaceAll("stream/", ""); var url = "http:" + ip + ":" + port + "/stream/receiver/" + streamid; var settings = { "url": url, "method": "POST", "timeout": 0, "headers": { "Content-Type": "application/x-www-form-urlencoded" }, "data": { "suuid": streamid, "data": BASE64.encode(offer.sdp) } }; $.ajax(settings).done(function (res) { var decode = BASE64.decode(res); resolve(decode) });
效果
标签:rtsp,url,RTSPtoWebRTC,html,video,streamid,var,webrtc From: https://www.cnblogs.com/chen1880/p/16785104.html