Answer the question
In order to leave comments, you need to log in
How to stream video from a computer screen to a web page?
It is necessary to broadcast video from the computer screen to a web page in real time. Keystrokes, clicks, etc. are also transmitted from the web page. it turns out such a collective farm RDP (This part is implemented and does not raise questions).
How it is now implemented
1. The C# console program is executed on the computer whose screen is to be translated.
2. The program takes a screenshot in jpeg format
3. The program sends a screenshot in binary form via WebSocket to the browser.
4. Next, js renders this image to the canvas.
var _canvas = document.getElementById("player");
var _ctx = _canvas.getContext("2d");
var _image = new Image();
_image.onload = function() {
_ctx.drawImage(_image, 0, 0);
};
socket.onmessage = function(event) {
URL.revokeObjectURL(_image.src);
_image.src = URL.createObjectURL(event.data);
};
Answer the question
In order to leave comments, you need to log in
you reinvented MJPEG. it is used in all kinds of video surveillance systems. due to the minimum amount of compression, it gives good still shots. the main drawback - for the same reason, it consumes a huge amount of traffic (really huge, a video for 5-10 minutes with FPS 20+ in this format will take a couple of GB). Above in the comments it was advised to use webrts. So, just in case - he's not fucking needed here. But you can pay attention to H.264 which is used there. That the video is in mjpeg, that h.264 can be simply and without unnecessary gestures opened in the browser as a stream. And native support for the video codec in the browser will work faster than rendering frames with Javascript.
2. The program takes a screenshot in jpeg format
3. The program sends a screenshot in binary form via WebSocket to the browser.
I thought about this topic.
To begin with, you are correctly told about webrtc, an open source project developed by Google.
Video streaming is more convenient, provided that there are many users. But it is not known how much your crutch with jpeg will fall, especially if you suddenly need to sharply increase FPS / image quality ...
Ps It is more stable to transmit video via webrtc, but now process keystrokes through normal request / response.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question