MediaStreamRecorder.js is a cross-browser implementation to record audio & video streams via WebRTC. The lib allows you to submit/upload recorded blobs in realtime to your server.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<script src="https://cdn.webrtc-experiment.com/MediaStreamRecorder.js"> </script> <script> var mediaConstraints = { audio: true, video: true }; navigator.getUserMedia(mediaConstraints, onMediaSuccess, onMediaError); function onMediaSuccess(stream) { var multiStreamRecorder = new MultiStreamRecorder(stream); multiStreamRecorder.video = yourVideoElement; // to get maximum accuracy multiStreamRecorder.audioChannels = 1; multiStreamRecorder.ondataavailable = function (blobs) { // blobs.audio // blobs.video }; multiStreamRecorder.start(3 * 1000); } function onMediaError(e) { console.error('media error', e); } </script> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php foreach(array('video', 'audio') as $type) { if (isset($_FILES["${type}-blob"])) { $fileName = $_POST["${type}-filename"]; $uploadDirectory = "uploads/$fileName"; if (!move_uploaded_file($_FILES["${type}-blob"]["tmp_name"], $uploadDirectory)) { echo("problem moving uploaded file"); } echo($uploadDirectory); } } ?> |
I am a full-stack developer. My expertise include:
I love programming, design and know my way around server architecture as well. I would never feel complete, with one of these missing.
I have a broad range of interests, that’s why I constantly dive into new technologies and expand my knowledge where ever required. Technologies are evolving fast and I enjoy using the latest.
Apart from that, I am a peace loving guy who tries to have people around him that think the same. I truly believe in the principle: “If you help someone, someone will help you, when you need it."
Great example! Do you have one that includes the screen capture code as well?
Thanks.
Hi Mark,
you can find an example here:
https://github.com/muaz-khan/RecordRTC/blob/master/simple-demos/video-plus-screen-recording.html
Alex