converting .wav file to .ogg in javascript

后端 未结 4 826
粉色の甜心
粉色の甜心 2021-02-05 01:42

I\'m trying to capture user\'s audio input from the browser. I have done it with WAV but the files are really big. A friend of mine told me that OGG files are much smaller. Does

4条回答
  •  别跟我提以往
    2021-02-05 02:13

    This question has been driving me crazy because I haven't seen anyone come up with a really clean solution, so I came up with my own library:

    https://github.com/sb2702/audioRecord.js

    Basic usage

    audioRecord.requestDevice(function(recorder){
      // Request user permission for microphone access
    
          recorder.record(); // Start recording
    
          recorder.stop();  /Stop recording
    
          recorder.exportOGG(function(oggBlob){
            //Here's your OGG file
          });
    
          recorder.exportMP3(function(mp3Blob){
                   //Here's your mp3 file
          });
    
          recorder.exportWAV(function(wavBlob){
                //Here's your WAV file
          });
    
    });
    

    Using the continuous mp3 encoding option, it's entirely reasonable to capture and encode audio input entirely in the browser, cross-browser, without a server or native code.

    DEMO: http://sb2702.github.io/audioRecord.js/

    It's still rough around the edges, but I'll try to clean / fix it up.

提交回复
热议问题