Recording html5 audio

前端 未结 3 1309
离开以前
离开以前 2020-12-14 04:49

Is it possible to record sound with html5 yet? I have downloaded the latest canary version of chrome and use the following code:

navigator.getUserMedia = navigator.w

3条回答
  •  我在风中等你
    2020-12-14 05:53

    Now it is possible to access the audio buffer using Audio context API and getChannelData().

    Here's a project on gitHub that records audio directly in MP3 format and saves it on the webserver: https://github.com/nusofthq/Recordmp3js

    In recorder.js you will see how the audio buffer is accessed individually by channels like so:

    this.node.onaudioprocess = function(e){
          if (!recording) return;
          worker.postMessage({
            command: 'record',
            buffer: [
              e.inputBuffer.getChannelData(0),
              //e.inputBuffer.getChannelData(1)
            ]
          });
        }
    

    For a more detailed explanation of the implementation you can read the following blogpost: http://nusofthq.com/blog/recording-mp3-using-only-html5-and-javascript-recordmp3-js/

提交回复
热议问题