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've set up my hardware to generate 48kHz PCM stream, within only 1 channel. Therefore, it generates 48000 / 320 = 150 frames per second. The problem is that I get OPUS_BAD_ARG from opus_encode caused by this piece of code:
The text was updated successfully, but these errors were encountered:
Hirrolot
changed the title
OPUS_BAD_ARG with srate=48kHz and frame size = 320opus_encode returns OPUS_BAD_ARG with srate=48kHz and frame size = 320
Jun 19, 2021
No, it's not possible to run the encoder at 150 frames a second. You must use a supported frame size. If your hardware isn't capable of using one of the possible frame sizes, you can insert a small ringbuffer to compensate.
We recommend 960 sample frames (20 ms at 48 kHz, or 50 frames per second) for most applications. Frames shorter than 10 ms reduce quality with little improvement to delay unless you're doing live audio.
int bytes_written = opus_encode(enc, data + (i * FRAME_SIZE), FRAME_SIZE, out, 4000);
Another issue is that the third argument to opus_encode is the number of samples, not the number of bytes. If you're reading 16-bit mono audio into a char * you need to divide by two when you pass the in input frame size.
Another issue is that the third argument to opus_encode is the number of samples, not the number of bytes. If you're reading 16-bit mono audio into a char * you need to divide by two when you pass the in input frame size.
In fact, FRAME_SIZE here is the number of samples, but I provide data + (i * FRAME_SIZE) as the second argument to opus_encode, which is wrong; data + (i * FRAME_SIZE * 2) would be correct.
I've set up my hardware to generate 48kHz PCM stream, within only 1 channel. Therefore, it generates 48000 / 320 = 150 frames per second. The problem is that I get
OPUS_BAD_ARG
fromopus_encode
caused by this piece of code:opus/src/opus_encoder.c
Line 629 in 61747bc
libopus thinks that 150 frames per second is invalid. Is it possible to solve the problem?
How to reproduce
The stream itself: audio.pcm.tar.gz.
Compiling:
The text was updated successfully, but these errors were encountered: