You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
2.0 KiB
49 lines
2.0 KiB
<html>
|
|
<head>
|
|
<title>Streamer</title>
|
|
</head>
|
|
<body>
|
|
https://github.com/mpromonet/webrtc-streamer
|
|
https://medium.com/@alexcambose/webcam-live-streaming-with-websockets-and-base64-64b1b4992db8
|
|
chrome://flags/#unsafely-treat-insecure-origin-as-secure
|
|
https://developer.mozilla.org/en-US/docs/Web/API/Media_Streams_API
|
|
https://www.tutorialspoint.com/webrtc/webrtc_media_stream_apis.htm
|
|
https://webrtc.github.io/samples/
|
|
https://phoboslab.org/log/2013/09/html5-live-video-streaming-via-websockets
|
|
https://github.com/phoboslab/jsmpeg
|
|
https://stackoverflow.com/questions/4241992/video-streaming-over-websockets-using-javascript
|
|
https://chromium.googlesource.com/chromium/src/+/master/net/server/web_socket_encoder.cc
|
|
https://tools.ietf.org/html/rfc7692#page-12
|
|
https://tools.ietf.org/html/rfc6455#section-4.2.2
|
|
https://habr.com/ru/company/ruvds/blog/342346/
|
|
https://github.com/liwf616/awesome-live-stream
|
|
https://github.com/auscaster/webrtc-native-to-browser-peerconnection-example/blob/master/peerconnection/server/main.cc
|
|
<video autoplay></video>
|
|
<script>
|
|
// get video dom element
|
|
const video = document.querySelector('video');
|
|
|
|
// request access to webcam
|
|
navigator.mediaDevices.getUserMedia({video: {width: 426, height: 240}}).then((stream) => video.srcObject = stream);
|
|
|
|
// returns a frame encoded in base64
|
|
const getFrame = () => {
|
|
const canvas = document.createElement('canvas');
|
|
canvas.width = video.videoWidth;
|
|
canvas.height = video.videoHeight;
|
|
canvas.getContext('2d').drawImage(video, 0, 0);
|
|
const data = canvas.toDataURL('image/png');
|
|
return data;
|
|
}
|
|
const WS_URL = 'ws://192.168.0.115:8080';
|
|
const FPS = 3;
|
|
const ws = new WebSocket(WS_URL);
|
|
ws.onopen = () => {
|
|
console.log(`Connected to ${WS_URL}`);
|
|
setInterval(() => {
|
|
ws.send(getFrame());
|
|
}, 1000 / FPS);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|