forked from alexcambose/webcam-base64-streaming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamer.html
34 lines (29 loc) · 802 Bytes
/
streamer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<html>
<head>
<title>Streamer</title>
</head>
<body>
<video autoplay></video>
<script>
const video = document.querySelector('video')
navigator.mediaDevices.getUserMedia({
video: true,
audio: true
}).then(stream => {
video.srcObject = stream
stream.onactive = e => console.log(e)
const ws = new WebSocket('ws://localhost:3000')
const recorder = new MediaRecorder(stream, { mimeType: 'video/webm;codecs=vp8,opus' })
recorder.ondataavailable = event => {
console.log(event.data)
ws.send(event.data)
}
recorder.start()
setInterval(() => {
recorder.stop()
recorder.start()
}, 200)
})
</script>
</body>
</html>