Gathering detailed insights and metrics for raw-opus-stream-recorder
Gathering detailed insights and metrics for raw-opus-stream-recorder
Gathering detailed insights and metrics for raw-opus-stream-recorder
Gathering detailed insights and metrics for raw-opus-stream-recorder
A library for encoding and decoding web audio as OggOpus.
npm install raw-opus-stream-recorder
Typescript
Module System
Node Version
NPM Version
JavaScript (98.72%)
HTML (1.04%)
Makefile (0.24%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
1 Stars
809 Commits
2 Forks
2 Branches
1 Contributors
Updated on Mar 31, 2021
Latest Version
1.0.2
Package Id
raw-opus-stream-recorder@1.0.2
Unpacked Size
514.84 kB
Size
242.54 kB
File Count
8
NPM Version
6.14.5
Node Version
12.18.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A javascript library originally forked from chris-rudmin/opus-recorder. This library handles encoding the output of Web Audio API nodes in
The underlying implementation uses webassembly transpiled audio libraries integrated into the Javascript API.
The required files are in the dist
folder. Unminified sources are in dist-unminified
.
Examples for recording, encoding, and decoding are in examples
folder.
The Recorder
object is available in the global namespace and supports CommonJS and AMD imports.
1import Recorder from 'raw-opus-recorder' 2var rec = new Recorder({config-object});
Creates a recorder instance.
4096
.encoderWorker.min.js
true
.0
and 1
. Defaults to 0
1
= mono, 2
= stereo. Defaults to 1
. Maximum 2
channels are supported.0
and 1
. Defaults to 1
2048
- Voice, 2049
- Full Band Audio, 2051
- Restricted Low Delay. Defaults to 2049
.0
is fastest with lowest complexity. 10
is slowest with highest complexity. The encoder selects a default when this is not specified.20
.48000
. Supported values are 8000
, 12000
, 16000
, 24000
or 48000
.40
.16000
.0
is fastest with lowest quality. 10
is slowest with highest quality. Defaults to 3
.dataAvailable
event will fire after each encoded page. Defaults to false
.false
.max_data_bytes
field in the call to opus_encode_float. defaults to 4000
16
. Supported values are 8
, 16
, 24
and 32
bits per sample.1rec.close()
close will close the audioContext, destroy the workers, disconnect the audio nodes and close the mic stream. A new Recorder instance will be required for additional recordings. if a sourceNode
was provided in the initial config, then the implementation will need to close the audioContext and close the mic stream.
1rec.pause([flush])
pause will keep the stream and monitoring alive, but will not be recording the buffers. If flush
is true
and streamPages
is set, any pending encoded frames of data will be flushed, and it will return a promise that only resolves after the frames have been flushed to ondataavailable
. Will call the onpause
callback when paused. Subsequent calls to resume will add to the current recording.
1rec.resume()
resume will resume the recording if paused. Will call the onresume
callback when recording is resumed.
1rec.setRecordingGain( gain )
setRecordingGain will set the volume on what will be passed to the recorder. Gain is an a-weighted value between 0
and 1
.
1rec.setMonitorGain( gain )
setMonitorGain will set the volume on what will be passed to the monitor. Monitor level does not affect the recording volume. Gain is an a-weighted value between 0
and 1
.
1rec.start()
start Begins a new recording. Returns a promise which resolves when recording is started. Will callback onstart
when started. start
needs to be initiated from a user action (click or touch) so that the audioContext can be resumed and the stream can have audio data.
1rec.stop()
stop will cease capturing audio and disable the monitoring and mic input stream. Will request the recorded data and then terminate the worker once the final data has been published. Will call the onstop
callback when stopped.
1rec.encodedSamplePosition
Reads the currently encoded sample position (the number of samples up to and including the most recent data provided to ondataavailable
). For Opus, the encoded sample rate is always 48kHz, so a time position can be determined by dividing by 48000.
1Recorder.isRecordingSupported()
Returns a truthy value indicating if the browser supports recording.
1Recorder.version
The version of the library.
1rec.ondataavailable( arrayBuffer )
A callback which returns an array buffer of audio data. If streamPages
is true
, this will be called with each page of encoded audio. If streamPages
is false
, this will be called when the recording is finished with the complete data.
If rawOpus is true, this will be called with each encoded opus packet.
1rec.onpause()
A callback which occurs when media recording is paused.
1rec.onresume()
A callback which occurs when media recording resumes after being paused.
1rec.onstart()
A callback which occurs when media recording starts.
1rec.onstop()
A callback which occurs when media recording ends.
Add to your webpack.config.js before all other loaders.
1module.exports = { 2 module: { 3 rules: [ 4 { 5 test: /encoderWorker\.min\.js$/, 6 use: [{ loader: 'file-loader' }] 7 } 8 ] 9 } 10};
Then get the encoderPath using an import
1import Recorder from 'raw-opus-stream-recorder'; 2import encoderPath from 'raw-opus-stream-recorder/dist/encoderWorker.min.js'; 3 4const rec = new Recorder({ encoderPath });
rec.start()
to be called from a user initiated event. In iOS and macOS Safari, the mic stream will be empty with no logged errors. In Chrome and Firefox the audioContext could be suspended.Supported:
Unsupported:
Prebuilt sources are included in the dist folder. However below are instructions if you want to build them yourself. Opus and speex are compiled without SIMD optimizations. Performace is significantly worse with SIMD optimizations enabled.
Mac: Install autotools using MacPorts
1port install automake autoconf libtool pkgconfig
Windows: Install autotools using MSYS2
1pacman -S make autoconf automake libtool pkgconfig
Install npm dependencies:
1npm install
checkout, compile and create the dist from sources:
1npm run make
Running the unit tests:
1npm test
Clean the dist folder:
1make cleanDist
Clean the dist folder and the submodules:
1make cleanAll
No vulnerabilities found.
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
Found 0/27 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
39 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More