我使用getUserMedia来访问camera.while使用getUserMedia播放捕获的视频。我想使用ffmpeg和ffserver将其流式传输并广播到我页面中的所有用户作为直播流。
如何将该流发布到服务器(ffserver)以实时流式传输?
以下是getUserMedia部分的代码
window.addEventListener('DOMContentLoaded', function() {
var v = document.getElementById('vlive');
navigator.getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia
|| navigator.mozGetUserMedia || navigator.msGetUserMedia);
if (navigator.getUserMedia) {
navigator.getUserMedia({
video: true,
audio: true,
},
function(stream) {
var url = window.URL || window.webkitURL;
v.src = url ? url.createObjectURL(stream) : stream;
v.play();
},
function(error) {
console.log('Good Job');
alert('Something went wrong. (error code ' + error.code + ')');
return;
});
} else {
alert('Sorry, the browser you are using doesn\'t support getUserMedia');
return;
}
});