user4893295
user4893295

Reputation: 651

How to take WebRTC audio and put on server

I have used the excellent demo audio recorder at https://webaudiodemos.appspot.com/AudioRecorder/index.html

However, I need the audio file to be on the server. Rather than undoing what I have done so far is there a way I can take the created audio file and upload it to the server neatly?

Ok so following on from the comment, I have now changed the code as follows using a bit of jquery (old code commented out):

  //Recorder.setupDownload = function(blob, filename){
  //  var url = (window.URL || window.webkitURL).createObjectURL(blob);
  //  var link = document.getElementById("save");
  //  link.href = url;
  //  link.download = filename || 'output.wav';
  //}

Recorder.setupDownload = function(blob, filename){
  $('#save').click(function(blob, filename) {
    $.ajax({
      url: 'process.php',
      type: 'post',
      filename: filename,
      success: function(data) {
        alert(data);
      }
    });
  });
}

Which I think is nearly there, but it's not passing the data through do the ajax (which I'm still new to!).

Upvotes: 0

Views: 292

Answers (1)

Adam Wright
Adam Wright

Reputation: 129

Just use the underlying RecorderJS and catch the packets from there. Then upload to your server via simple AJAX requests (HTTP POST). You will need to write some server side script to handle these packets and write to file.

Alternatively you can use a WebRTC server with built-in audio recording capabilities.

Upvotes: 1

Related Questions