webRtc之指定摄像头设备绿屏问题

摘要:最近发现,在使用navigator.mediaDevices.getUserMedia({ deviceId: 'xxx'}),指定设备的时候,video播放总是绿屏,发现关闭浏览器硬件加速不会出现,但显然这不是一个最好的方案;

播放后张这样
修复后
上代码

指定采集宽度高度后就不会出现这个绿屏问题

typescript 复制代码
// js
navigator.mediaDevices.getUserMedia({
	video: {
		deviceId: devId,
		// 指定采集尺寸
		width: { ideal: 1280 },
		height: { ideal: 720 },
	}
}).then((stream) => {
     const elm: HTMLVideoElement | any = document.getElementById('devDetectionVideoRef');
     if (elm) {
         elm.srcObject = stream;
     }
}).catch((error) => {
})
// html
<video id="devDetectionVideoRef" className={style.video_element}
	autoPlay
	playsInline
	webkit-playsinline='true'
></video>
// css
.video_element{
	width: 640px;
	height: 480px;
	background-color: #233149;
}
相关推荐
SendTomo3 天前
send.wang(私传网)基于网页P2P直连传输大文件的优势
javascript·网络·webrtc·html5·p2p
SendTomo5 天前
SendTomo稳定传输三大核心策略
javascript·网络协议·webrtc·html5·p2p
SendTomo5 天前
send.wang(私传网)P2P直连加速文件传输
网络·网络协议·webrtc·html5·p2p
简简单单lym7 天前
mediasou c++分析--流分析
笔记·webrtc
SoStraw7 天前
webrpc 常见问题 FAQ:无公网 IP、Token、传文件,以及和 frp / WebRTC 的差别
tcp/ip·webrtc·frp·token·faq·webrpc·无公网ip
SendTomo8 天前
P2P文件传输工具对比:SendTomo vs send.wang
javascript·网络协议·webrtc·html5·p2p
SendTomo8 天前
WebRTC文件互传工具实测对比
javascript·网络·webrtc·html5·p2p
SendTomo8 天前
send.wang自托管+WSS保障信令安全方案
网络·网络协议·webrtc·html5·p2p
SendTomo9 天前
跨设备文件互传新方案
javascript·网络·webrtc·html5·p2p
红尘散仙10 天前
浏览器不能监听端口、没有文件系统,凭什么能点对点传文件?
rust·webrtc·webassembly