我正在尝试从div中提取视频,该div是来自网络上几台记录器之一。我知道它正在使用webRTC来流式传输视频-参见下文。
到目前为止,我对此的测试是流式传输本地网络摄像头,但是当我从本地网络摄像头(localstream)更改为指向远程录像机时,我遇到了问题。我对双向通讯或录音机的音频不感兴趣。下面是javascript代码段。
'use strict';
// Streaming only video (video: true).
const mediaStreamConstraints = {
video: true,
};
// Video element where stream will be placed.
const localVideo = document.querySelector('video');
// Local stream that will be reproduced on the video.
let localStream;
// Handles success by adding the MediaStream to the video element.
function gotLocalMediaStream(mediaStream) {
localStream = mediaStream;
localVideo.srcObject = mediaStream;
}
// Handles error by logging a message to the console with the error message.
function handleLocalMediaStreamError(error) {
console.log('navigator.getUserMedia error: ', error);
}
// Initializes media stream.
navigator.mediaDevices.getUserMedia(mediaStreamConstraints)
.then(gotLocalMediaStream).catch(handleLocalMediaStreamError);
感谢您的任何建议:)