I have a RTMP Server (node-media-server) where i can send stream from OBS and watch them in Browsers. To make the sending process easier i want to send streams directly from Browser.
1st idea was to get the Streamdata with navigator.getUserMedia()
const getVideo = () => {
navigator.mediaDevices
.getUserMedia({ video: { width: 300 } })
.then(stream => {
let video = videoRef.current;
video.srcObject = stream;
video.play();
})
.catch(err => {
console.error("error:", err);
});
};
this shows the media in a video element. is there a way to send this stream live to rtmp? Maybe i have to create a new MediaRecorder Object, but how i can send it? is there another way as websocket to send it?
all ideas to get a startpoint are welcome.
update 1
i have created a MediaRecorder Object and send it with Websocket:
.then(stream => {
let mediaRecorder = new MediaRecorder(stream);
mediaRecorder.start(250);
mediaRecorder.ondataavailable = function(e) {
ws.send(e.data);
}
//...
}
on node.js side
ws._socket.on('data', (data) => console.log('incoming_data'));
console:
Eߣ�B��B��B�BB��matroskaB��B��S�g�������I�f�*ױ�B@M��ChromeWA�ChromeT�k���ׁsŇ��v0��烁��V_MPEG4/ISO/AVC��������C�u��������
not sure this is correct. when its correct, how i can give this data to node-media-server?