@vikasietum_tecknology/record-rtc
Version:
record-rtc is a library based on recordrtc library. In this forked version of the original library we have optimized the memory management. The video recording is stored in IndexDB in chunks.
64 lines (48 loc) • 1.66 kB
HTML
<style>
html, body {
margin: 0;
padding: 0;
}
</style>
<title>pass getUserMedia constraints to RecordRTC</title>
<h1>pass getUserMedia constraints to RecordRTC</h1>
<br>
<button id="btn-start-recording">Start Recording</button>
<button id="btn-stop-recording" disabled>Stop Recording</button>
<hr>
<video controls autoplay playsinline></video>
<script src="/RecordRTC.js"></script>
<script>
var video = document.querySelector('video');
function stopRecordingCallback() {
video.src = video.srcObject = null;
video.src = URL.createObjectURL(recorder.getBlob());
recorder.camera.stop();
recorder.destroy();
recorder = null;
}
var recorder; // globally accessible
document.getElementById('btn-start-recording').onclick = function() {
this.disabled = true;
// Example snippet
var constraints = {
video: { width: 360, height: 240 },
audio: true,
// recorderType: WhammyRecorder
};
navigator.mediaDevices.getUserMedia(constraints).then(function(camera) {
video.srcObject = camera;
recorder = RecordRTC(camera, constraints);
recorder.startRecording();
// release camera on stopRecording
recorder.camera = camera;
document.getElementById('btn-stop-recording').disabled = false;
});
};
document.getElementById('btn-stop-recording').onclick = function() {
this.disabled = true;
recorder.stopRecording(stopRecordingCallback);
};
</script>
<footer style="margin-top: 20px;"><small id="send-message"></small></footer>
<script src="https://www.webrtc-experiment.com/common.js"></script>