webrtc学习

597

浏览器获取视频并显示:
var video = document.querySelector(‘video’);
navigator.mediaDevices.getUserMedia(constraints).then(handleSuccess).catch(handleError);
var constraints = window.constraints = {
audio: false,
video: true
};
function handleSuccess(stream) {
var videoTracks = stream.getVideoTracks();
console.log(‘Got stream with constraints:’, constraints);
console.log(‘Using video device: ‘ + videoTracks[0].label);
stream.oninactive = function() {
console.log(‘Stream inactive’);
};
window.stream = stream; // make variable available to browser console
video.srcObject = stream;
}

linux下使用:
pip3 install aiortc websockets

留下一个答复

Please enter your comment!
Please enter your name here