[opus] OPUS encoded data size and bandwidth of encoder

Ralph Giles giles at thaumas.net
Thu Jun 11 17:02:12 UTC 2020


On Thu, 2020-06-11 at 18:58 +0500, Abdullah Sajjad wrote:

> opus_encoder_ctl(enc, OPUS_GET_BANDWIDTH(&x)) = 1102
> opus_encoder_ctl(enc, OPUS_GET_MAX_BANDWIDTH(&x)) = 1103
> average encoded size = 120 bytes

OPUS_GET_BANDWIDTH defaults to OPUS_AUTO. Since it's returning
OPUS_BANDWIDTH_MEDIUMBAND (1102) presumedly you set this elsewhere in
your programme?

OPUS_GET_MAX_BANDWIDTH is returning OPUS_BANDWIDTH_WIDEBAND (1103)
which is the value you set, so that is expected.

> opus_encoder_ctl(enc, OPUS_GET_BANDWIDTH(&x)) = 1103 
> opus_encoder_ctl(enc, OPUS_GET_MAX_BANDWIDTH(&x)) = 1103
> average encoded size = 280 bytes

Here both are returning the WIDEBAND value. I believe MAX_BANDWIDTH
defaults to OPUS_BANDWIDTH_FULLBAND so presumedly you also set this
somehwere?

Note that we recommend you _only_ set OPUS_MAX_BANDWIDTH, leaving
OPUS_BANDWIDTH set to OPUS_AUTO. This allows the encoder to adapt to
lower-quality signals, allowing better compression.

> I do not understand why 48khz encoded data has more bytes even when I
> am asking it to encode to a smaller frequency range.

According to the values you've posted, the encoder is using MEDIUMBAND
for the 16 kHz input. The narrower bandpass may explain the difference.

You also don't mention calling OPUS_SET_BITRATE. The default bitrate
depends on the input sample rate, so the encoder may feel it has room
for a higher-quality encoding with your 48 kHz input even with the same
bandpass. Try setting the same explicit bitrate target for both and see
if that improves the result.

Cheers,
Ralph



More information about the opus mailing list