Javascript can now record, manipulate and play sound thanks to a whole range of audio-related API’s. One of the simpler and more useful parts of that is MediaRecorder which can record sound, typically from the user’s microphone.

``` const stream = await navigator.mediaDevices .getUserMedia({audio: true, video: false}); // Media Capture and Streams API const mediaRecorder = new MediaRecorder(stream); // MediaStream Recording API mediaRecorder.ondataavailable = (ev) => { // ev is a BlobEvent // ev.data is a Blob. Send it to the server. }; mediaRecorder.start(50); // call ondataavailable every 50ms

```

MediaRecorder on Chrome produces output with mime type audio/webm;codecs=opus.

Let me guide you through the WebM / Matroska / EBML maze.

The WebM format is a container, which can contain many things. In our case it contains audio encoded with the Opus codec. We are only going to look at the container, not the encoded audio.