Closed herenickname closed 5 years ago
node-opus is bindings to libopus (with some "easier to use from JS" benefits such as no need to pass the array length separately). You need to follow libopus requirements.
http://opus-codec.org/docs/opus_api-1.2/group__opus__encoder.html
[in] | frame_size | int: Number of samples per channel in the input signal. This must be an Opus frame size for the encoder's sampling rate. For example, at 48 kHz the permitted values are 120, 240, 480, 960, 1920, and 2880. |
---|
So @ekifox how did you solve this?
@s4kh I went the other way :)
import { OpusEncoder, Encoder as OpusEncoderStream } from 'node-opus'
import { Encoder as OggEncoder } from 'ogg'
import { WriteStream } from 'fs'
const opusEncoder = new OpusEncoder(48000)
export default function OpusFactory(audios: Buffer[], writeStream: WriteStream) {
const opusEncodeStream = new OpusEncoderStream(48000, 1)
const oggEncoder = new OggEncoder()
opusEncodeStream.pipe(oggEncoder.stream())
oggEncoder.pipe(writeStream)
for (const part of audios) {
const rawAudio = opusEncoder.decode(part)
opusEncodeStream.write(rawAudio)
}
opusEncodeStream.end()
}
15360 node: ../../nan/nan.h:904: Nan::MaybeLocal Nan::CopyBuffer(const char*, uint32_t): Assertion `size <= imp::kMaxLength && "too large buffer"' failed.
Aborted