HTML5 video recording


I would like to create a simple video streaming app by using HTML5 features + Node.js on the server side (actually I am not sure this is possible...). Now I have some important questions:

  • Is it possible to record the local stream created by the navigator.getUserMedia() API? I read lots of articles but everywhere it is just used to define the source of a HTML5 video element.
  • Is it possible to send this stream through websockets? (, binaryjs,... ?). Otherwise I can only imagine sending frames to a canvas element, and I am not sure that is a good solution.
  • Is there any Node.js module that supports load balancing? It would be interesting to work with different node servers.

Thank you all in advance.

10/8/2012 5:59:20 PM

MediaStreamRecorder is a WebRTC API for recording getUserMedia() streams . It allows web apps to create a file from a live audio/video session.

 <video autoplay></video>

    <script language="javascript" type="text/javascript">
    function onVideoFail(e) {
        console.log('webcam fail!', e);

    function hasGetUserMedia() {
      // Note: Opera is unprefixed.
      return !!(navigator.getUserMedia || navigator.webkitGetUserMedia ||
                navigator.mozGetUserMedia || navigator.msGetUserMedia);

    if (hasGetUserMedia()) {
      // Good to go!
    } else {
      alert('getUserMedia() is not supported in your browser');

    window.URL = window.URL || window.webkitURL;
    navigator.getUserMedia  = navigator.getUserMedia || 
                             navigator.webkitGetUserMedia ||
                              navigator.mozGetUserMedia || 

    var video = document.querySelector('video');
    var streamRecorder;
    var webcamstream;

    if (navigator.getUserMedia) {
      navigator.getUserMedia({audio: true, video: true}, function(stream) {
        video.src = window.URL.createObjectURL(stream);
        webcamstream = stream;
    //  streamrecorder = webcamstream.record();
      }, onVideoFail);
    } else {
        alert ('failed');

    function startRecording() {
        streamRecorder = webcamstream.record();
        setTimeout(stopRecording, 10000);
    function stopRecording() {
    function postVideoToServer(videoblob) {

        var data = {}; = videoblob;
        data.metadata = 'test metadata';
        data.action = "upload_video";"", data, onUploadSuccess);
    function onUploadSuccess() {
        alert ('video uploaded');


    <div id="webcamcontrols">
        <button class="recordbutton" onclick="startRecording();">RECORD</button>


MediaElements have to new method to capture streams, have a look at below article

4/14/2017 10:18:55 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow