/
WebAssemblyRecorder.html
70 lines (58 loc) · 1.93 KB
/
WebAssemblyRecorder.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<title>WebAssembly Recorder using RecordRTC</title>
<style type="text/css">
body {
text-align: center;
}
video {
border-radius: 5px;
border: 1px solid black;
}
</style>
<h1>WebAssembly Recorder using RecordRTC <span id="version"></span></h1>
<button id="start">Start Recording</button>
<button id="stop" disabled>Stop Recording</button>
<br><br>
<video id="video" controls autoplay playsinline></video>
<!-- web streams API polyfill to support Firefox -->
<script src="https://unpkg.com/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js"></script>
<script src="/RecordRTC.js"></script>
<script>
document.getElementById('version').innerHTML = RecordRTC.version;
var recorder;
document.getElementById('start').onclick = function() {
this.disabled = true;
navigator.mediaDevices.getUserMedia({
video: {
width: {
ideal: 640
},
height: {
ideal: 480
}
},
audio: false
}).then(function(stream) {
document.getElementById('video').srcObject = stream;
recorder = RecordRTC(stream, {
recorderType: WebAssemblyRecorder,
// workerPath: '../libs/webm-worker.js',
// webAssemblyPath: '../libs/webm-wasm.wasm',
width: 640,
height: 480,
frameRate: 30
});
recorder.startRecording();
document.getElementById('stop').disabled = false;
});
};
document.getElementById('stop').onclick = function() {
document.getElementById('video').srcObject = null;
this.disabled = true;
recorder.stopRecording(function(blob) {
document.getElementById('video').src = URL.createObjectURL(recorder.getBlob());
document.getElementById('start').disabled = false;
});
}
</script>
<footer style="margin-top: 20px;"><small id="send-message"></small></footer>
<script src="https://www.webrtc-experiment.com/common.js"></script>