Web UI for ARGUS server
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.

48 lines
2.0 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <title>Streamer</title>
  4. </head>
  5. <body>
  6. https://github.com/mpromonet/webrtc-streamer
  7. https://medium.com/@alexcambose/webcam-live-streaming-with-websockets-and-base64-64b1b4992db8
  8. chrome://flags/#unsafely-treat-insecure-origin-as-secure
  9. https://developer.mozilla.org/en-US/docs/Web/API/Media_Streams_API
  10. https://www.tutorialspoint.com/webrtc/webrtc_media_stream_apis.htm
  11. https://webrtc.github.io/samples/
  12. https://phoboslab.org/log/2013/09/html5-live-video-streaming-via-websockets
  13. https://github.com/phoboslab/jsmpeg
  14. https://stackoverflow.com/questions/4241992/video-streaming-over-websockets-using-javascript
  15. https://chromium.googlesource.com/chromium/src/+/master/net/server/web_socket_encoder.cc
  16. https://tools.ietf.org/html/rfc7692#page-12
  17. https://tools.ietf.org/html/rfc6455#section-4.2.2
  18. https://habr.com/ru/company/ruvds/blog/342346/
  19. https://github.com/liwf616/awesome-live-stream
  20. https://github.com/auscaster/webrtc-native-to-browser-peerconnection-example/blob/master/peerconnection/server/main.cc
  21. <video autoplay></video>
  22. <script>
  23. // get video dom element
  24. const video = document.querySelector('video');
  25. // request access to webcam
  26. navigator.mediaDevices.getUserMedia({video: {width: 426, height: 240}}).then((stream) => video.srcObject = stream);
  27. // returns a frame encoded in base64
  28. const getFrame = () => {
  29. const canvas = document.createElement('canvas');
  30. canvas.width = video.videoWidth;
  31. canvas.height = video.videoHeight;
  32. canvas.getContext('2d').drawImage(video, 0, 0);
  33. const data = canvas.toDataURL('image/png');
  34. return data;
  35. }
  36. const WS_URL = 'ws://192.168.0.115:8080';
  37. const FPS = 3;
  38. const ws = new WebSocket(WS_URL);
  39. ws.onopen = () => {
  40. console.log(`Connected to ${WS_URL}`);
  41. setInterval(() => {
  42. ws.send(getFrame());
  43. }, 1000 / FPS);
  44. }
  45. </script>
  46. </body>
  47. </html>