Search code examples
javascriptwebaudiovideo

Extract audio from a video blob with vanilla JavaScript


On a web page, after recording screen video and audio using navigator.mediaDevices.getDisplayMedia and a MediaRecorder, I end up with a video blob. How can I extract using only vanilla JavaScript on the client the audio from that blob and for example have it downloaded to the user? I'm simply looking for this function:

async function extractAudio(videoBlob) {
  // ...

  return audioBlob;
}

Solution

  • I made it work with the video-to-audio npm package. It wasn't working at first but now it's all good.