You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have very simple encoder as below,
I try to encode 128 channels where I have sine wave on every channel,
I set total bitrate as 64kbps * 128 = 8192kbps
So I instantiate Encoder as follows:
Encoder encoder(8192, 48000, 128);
Actual result:
Audio corrupted on last channels, up to total loss of audio in last channel.
Issue can be reproduced on any number of channels depending on set total bitrate.
Expected result:
Audio should be of good quality in every channel if set total bitrate as 64kbps * channels
Results on different bitrates:
total bitrate 8192kbps - no audio on 128th channel at all:
total bitrate 16384kbps - it's 128kbps per channel, still 128th channel is corrupted:
Workaround:
Only after setting total bitrate to 20480kbps audio looks fine.
Encoder::Encoder(int bitrateKbps, int sampleRate, int numChannels)
{
int error = 0;
msEncoder_ = opus_multistream_encoder_create(sampleRate, numChannels, numChannels, 0, kChannelMapping.data(), OPUS_APPLICATION_AUDIO, &error);
if (error != OPUS_OK)
throw std::logic_error(std::string("Failed to create opus mulistream encoder, error: ") + opus_strerror(error));
opus_multistream_encoder_ctl(msEncoder_, OPUS_SET_BITRATE(bitrateKbps * 1000));
opus_multistream_encoder_ctl(msEncoder_, OPUS_SET_VBR(0));
opus_multistream_encoder_ctl(msEncoder_, OPUS_SET_PACKET_LOSS_PERC(5));
opus_multistream_encoder_ctl(msEncoder_, OPUS_SET_COMPLEXITY(5));
opus_multistream_encoder_ctl(msEncoder_, OPUS_SET_BANDWIDTH(OPUS_AUTO));
}
Encoder::~Encoder()
{
opus_multistream_encoder_destroy(msEncoder_);
}
bool Encoder::encode(const float* inBuf, int numInputSamples, unsigned char *outBuf, int outBufCapacity, int& encBytes)
{
encBytes = opus_multistream_encode_float(msEncoder_, inBuf, numInputSamples, outBuf, outBufCapacity);
if (encBytes < 0)
{
return false;
}
return true;
}
The text was updated successfully, but these errors were encountered:
NickolayGerasimenko
changed the title
Corrupted audio while encode of 128 channels
Opus 1.4 Corrupted audio while encode of 128 channels
Apr 11, 2025
Environment
Opus 1.4 (commit: 82ac57d)
OS: Win/MacOS
Repro steps
I have very simple encoder as below,
I try to encode 128 channels where I have sine wave on every channel,
I set total bitrate as 64kbps * 128 = 8192kbps
So I instantiate Encoder as follows:
Encoder encoder(8192, 48000, 128);
Actual result:
Audio corrupted on last channels, up to total loss of audio in last channel.
Issue can be reproduced on any number of channels depending on set total bitrate.
Expected result:
Audio should be of good quality in every channel if set total bitrate as 64kbps * channels
Results on different bitrates:
total bitrate 8192kbps - no audio on 128th channel at all:
total bitrate 16384kbps - it's 128kbps per channel, still 128th channel is corrupted:
Workaround:
Only after setting total bitrate to 20480kbps audio looks fine.
The text was updated successfully, but these errors were encountered: