Open vinnitu opened 2 years ago
First of all, the decoded frames are located in in "frames" sub property, and not the root object, so you would need to change your encode line to: const p = encoder.encode(frame.frames). Also you need to specify additional opus specific encoding parameters on the encoder like this: (example)
let encoder = beamcoder.encoder({ name: 'libopus', bit_rate: 128000, time_base: [1, 48000], sample_rate: 48000, channels: 1, channel_layout: 'mono', interleaved: false, sample_fmt: 'flt', });
Additionally, if the source "sample_fmt" is not in either s16 or flt bit format (the only possible for opus) you will need a filter in between the decode and encode steps to convert the source format to the destination format defined in the decoder, it's not automatic.