代码改变世界

WebRTC 显示RTSP视频流

  Evan.Pei  阅读(750)  评论(0编辑  收藏  举报

网页显示视频的两种方式:

 1.使用Vlc插件,浏览器限制火狐50,51 版本。文件见上传。

复制代码
<object type="application/x-vlc-plugin" id="vlc3" events="True" style="width:300px; height:300px;">
                <param name="mrl" id="mr103" value="rtsp://admin:yado1234@172.16.6.219:554/Streaming/Channels/101">
                <param name="autoplay" value="true">
        </object>
View Code
复制代码

 2.使用WebRTC将码流到指定服务器中转。文件见上传。运行WEVRTC服务.

复制代码
<div><video id="video1" autoplay muted preload="auto"></video></div>

        var webRtcServer1 = null;
        window.onload = function () {
            var rtcServerURL;
            if (location.protocol.toLowerCase().indexOf("http") != -1) {
                rtcServerURL = location.protocol + "//" + window.location.hostname + ":9876";
            } else {
                rtcServerURL = "http://127.0.0.1:9001";//中转服务器地址
            }

            webRtcServer1 = new WebRtcStreamer("video1", rtcServerURL);
            webRtcServer1.connect("rtsp://admin:yado1234@172.16.6.219:554/Streaming/Channels/101", "", webrtcConfig.options);//rtsp流

            window.onbeforeunload = function () {
                        webRtcServer1.disconnect();
                        return "关闭提示";
                    }
View Code
复制代码

 https://github.com/mpromonet/webrtc-streamer/releases               //webrtc   exe下载地址

命令行输入webrtc-streamer.exe -H 0.0.0.0:9001启动服务

推荐使用InstallService.bat运行。

 --------------------------------------------------上面的方法很占CPU,下面邹工已经优化,推荐

见csdn文件     WebRtc视频流.rar    https://download.csdn.net/download/qq_32768235/88225558

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2017-08-08 软件注册
点击右上角即可分享
微信分享提示