Constructor
new Encoder(options)
Creates a new Opus encoder stream.
Parameters:
Name |
Type |
Description |
options |
Object
|
options that you would pass to a regular OpusStream, plus a few more:
Properties
Name |
Type |
Description |
frameSize |
number
|
the frame size in bytes to use (e.g. 960 for stereo audio at 48KHz with a frame
duration of 20ms) |
channels |
number
|
the number of channels to use |
rate |
number
|
the sampling rate in Hz |
|
- Source:
Example
const encoder = new prism.opus.Encoder({ frameSize: 960, channels: 2, rate: 48000 });
pcmAudio.pipe(encoder);
// encoder will now output Opus-encoded audio packets
Extends
Methods
setBitrate(bitrate)
Sets the bitrate of the stream.
Parameters:
Name |
Type |
Description |
bitrate |
number
|
the bitrate to use use, e.g. 48000 |
- Overrides:
- Source:
setFEC(enabled)
Enables or disables forward error correction.
Parameters:
Name |
Type |
Description |
enabled |
boolean
|
whether or not to enable FEC. |
- Overrides:
- Source:
setPLP(percentageopt)
Sets the expected packet loss over network transmission.
Parameters:
Name |
Type |
Attributes |
Description |
percentage |
number
|
<optional>
|
a percentage (represented between 0 and 1) |
- Overrides:
- Source: