<html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <video id='video' autoplay></video> <script src="adapter.js"></script> <script> var video = document.getElementById('video'); navigator.getUserMedia({ video: true }, function(stream) { video.src = window.URL.createObjectURL(stream); video.play(); }, function(error) { alert(error.name || error); }); </script> </html>
参考:http://www.voidcn.com/article/p-wkjsdblk-bdp.html
以前看到不少博客写webtrc不支持h264格式视频,其实这个应该说是[不优先采用]。
应为webrtc在编码时优先采用
一、vp8
二、vp9
三、h264
因此若是不修改源码,那么视频采集端将以vp8的格式编码,播放段也会以vp8格式解码。
以前看到的都是关于native app开发的,听说编解码效率会高一些。
若是是浏览器之间呢?我要想这么搞不是有病啊。
若是是浏览器和网络摄像头呢?摄像头是rtsp(h264)流,只须要一个webrtc服务器,浏览器彻底能够播放。html