Skip to content

guest271314/MP3Recorder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MP3Recorder

Record MediaStreamTrack to MP3 file in the browser

Usage

var stream = await navigator.mediaDevices.getUserMedia({
  audio: {
    channelCount: 2,
    sampleRate: 44100,
    noiseSuppression: false,
    autoGainControl: false,
    echoCancellation: false,
  }
});
var [audioTrack] = stream.getAudioTracks();

var recorder = await new MP3Recorder(audioTrack);
var start = await recorder.start();
recorder.stop().then(async(blob) => {
  console.log(URL.createObjectURL(blob));
  var handle = await showSaveFilePicker({
    suggestedName: "download.mp3",
    startIn:'music'
  });
  blob.stream().pipeTo(await handle.createWritable())
}).catch(console.error);

Dependencies

mp3.

MP3 (license) references

License

Do What the Fuck You Want to Public License WTFPLv2