All Projects → chrisguttandin → extendable-media-recorder

chrisguttandin / extendable-media-recorder

Licence: MIT license
An extendable drop-in replacement for the native MediaRecorder.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
shell
77523 projects

Projects that are alternatives of or similar to extendable-media-recorder

Audio Speaker
Output audio stream to speaker, browser/node-wise
Stars: ✭ 97 (-21.14%)
Mutual labels:  web-audio
Guitarstack
Digital guitar effects right in your browser!
Stars: ✭ 164 (+33.33%)
Mutual labels:  web-audio
Timidity
Play MIDI files in the browser w/ Web Audio, WebAssembly, and libtimidity
Stars: ✭ 221 (+79.67%)
Mutual labels:  web-audio
Cracked
Mac app for noise making - built w/ "I Dropped My Phone The Screen Cracked"
Stars: ✭ 98 (-20.33%)
Mutual labels:  web-audio
Tone.js
A Web Audio framework for making interactive music in the browser.
Stars: ✭ 11,352 (+9129.27%)
Mutual labels:  web-audio
Wax
An experimental, JSX-compatible renderer for the Web Audio API
Stars: ✭ 171 (+39.02%)
Mutual labels:  web-audio
Sema
Sema – Live Code Language Design Playground
Stars: ✭ 80 (-34.96%)
Mutual labels:  web-audio
voder
An emulation of the Voder Speech Synthesizer.
Stars: ✭ 19 (-84.55%)
Mutual labels:  web-audio
Fetch Stream Audio
Low Latency web audio playback examples for decoding audio streams in chunks with Fetch & Streams APIs
Stars: ✭ 153 (+24.39%)
Mutual labels:  web-audio
Audioworklet Polyfill
🔊 Polyfill AudioWorklet using the legacy ScriptProcessor API.
Stars: ✭ 179 (+45.53%)
Mutual labels:  web-audio
Freedrum.js
Interact with the browser using the Freedrum sensors in JavaScript
Stars: ✭ 115 (-6.5%)
Mutual labels:  web-audio
R Audio
A library of React components for building Web Audio graphs.
Stars: ✭ 129 (+4.88%)
Mutual labels:  web-audio
Tonejs Instruments
A small instrument sample library with quick-loader for tone.js
Stars: ✭ 172 (+39.84%)
Mutual labels:  web-audio
Tuna
An audio effects library for the Web Audio API.
Stars: ✭ 1,345 (+993.5%)
Mutual labels:  web-audio
Audion
Audion (Web Audio Inspector) is a Chrome extension that adds a Web Audio panel to Developer Tools. This panel visualizes the web audio graph in real-time and lets users inspect nodes.
Stars: ✭ 230 (+86.99%)
Mutual labels:  web-audio
Beep.js
Beep is a JavaScript toolkit for building browser-based synthesizers.
Stars: ✭ 1,294 (+952.03%)
Mutual labels:  web-audio
Sono
A simple yet powerful JavaScript library for working with Web Audio
Stars: ✭ 164 (+33.33%)
Mutual labels:  web-audio
Tonalhub
Make your GitHub repository sing. Tonalhub will take the last year's commit activity and play it with web audio.
Stars: ✭ 18 (-85.37%)
Mutual labels:  web-audio
I dropped my phone the screen cracked
web audio, cracked.
Stars: ✭ 245 (+99.19%)
Mutual labels:  web-audio
Audiomotion.js
High-resolution real-time spectrum analyzer and music player using Web Audio and Canvas APIs.
Stars: ✭ 177 (+43.9%)
Mutual labels:  web-audio

extendable-media-recorder

An extendable drop-in replacement for the native MediaRecorder.

version

This package provides (a part of) the MediaRecorder API as defined by the MediaStream Recording specification. If possible it will use the native implementation.

In addition this package also allows to define custom encoders. Those encoders can be used to render files which are not supported by any browser so far. This does currently only work for audio encoders.

Usage

extendable-media-recorder is available on npm and can be installed as usual.

npm install extendable-media-recorder

It exports the MediaRecorder constructor. It can be used like the native implementation. The following example will use the default encoder that is defined by the browser.

import { MediaRecorder } from 'extendable-media-recorder';

const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
const mediaRecorder = new MediaRecorder(stream);

Using a custom encoder

extendable-media-recorder also exports a register() function which can be used to define custom encoders. One predefined encoder is available as the extendable-media-recorder-wav-encoder package. It can be used as shown here.

import { MediaRecorder, register } from 'extendable-media-recorder';
import { connect } from 'extendable-media-recorder-wav-encoder';

await register(await connect());

const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
const mediaRecorder = new MediaRecorder(stream, { mimeType: 'audio/wav' });

Setting the sample rate

The MediaRecoder has no way to modify the sample rate directly. It uses the sampleRate of the given MediaStream. You can read the value being used like this:

const { sampleRate } = stream.getAudioTracks()[0].getSettings();

To modifiy the sample rate of the recording you need to change the sampleRate of the MediaStream. But that's not possible either. Therefore the most reliable way is to use an AudioContext at the desired sampleRate to do the resampling.

const audioContext = new AudioContext({ sampleRate: 16000 });
const mediaStreamAudioSourceNode = new MediaStreamAudioSourceNode(audioContext, { mediaStream: stream });
const mediaStreamAudioDestinationNode = new MediaStreamAudioDestinationNode(audioContext);

mediaStreamAudioSourceNode.connect(mediaStreamAudioDestinationNode);

const mediaRecorder = new MediaRecorder(mediaStreamAudioDestinationNode.stream);

Inner Workings

Internally two different techniques are used to enable custom encoders. In Chrome the native MediaRecorder is used to encode the stream as webm file with pcm encoded audio. Then a minimal version of ts-ebml is used to parse that pcm data to pass it on to the encoder. In other browsers the Web Audio API is used to get the pcm data of the recorded audio.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].