-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
opus codec bad voice quality #20
Comments
I dumped at the receiving end a sample of audio that baresip android sent using opus codec: https://box.tutpro.com/tmp/dump-2018-05-11-15-57-52-enc.wav As you can hear, the first second or so is OK and after that the trouble starts. |
I also tried with speex codec and again voice quality was fine. So it is only opus that has the issue. |
We should first try to establish if the problem is in the audio driver The auloop module will create a local audio loop where the recorded input
Regarding the building of libopus, does it matter which Android NDK was used ?
Alfred |
Alfred E. Heggestad writes:
Regarding the building of libopus, does it matter which Android NDK was used ?
Perhaps also try to compile it with fixed point, by adding this:
```
--enable-fixed-point compile without floating point (for machines without
a fast enough FPU)
```
I only have one NDK (r16) installed. I tried with --enable-fixed-point
and perhaps audio quality was slightly better than without it, but still
much worse than G7221 or speex.
Regarding /auloop, I need to first implement it in my Android app,
…-- Juha
|
Alfred E. Heggestad writes:
We should first try to establish if the problem is in the audio driver
or in the opus codec.
The auloop module will create a local audio loop where the recorded input
is just played out, and no audio codecs are involved. Can you please test
the `/auloop` command on your device with the sample rates listed in
auloop.c:
```
static const struct {
uint32_t srate;
uint32_t ch;
} configv[] = {
{ 8000, 1},
{16000, 1},
{32000, 1},
{44100, 1},
{48000, 1},
{ 8000, 2},
{16000, 2},
{32000, 2},
{44100, 2},
{48000, 2},
};
```
How does one select the rate and channel count or how to go to the next
one? It starts with 8000/1, which sounds OK on my Android device.
…-- Juha
|
Found out how to go to the next rate/ch: give auloop command again.
…-- Juha
|
Alfred E. Heggestad writes:
The auloop module will create a local audio loop where the recorded input
is just played out, and no audio codecs are involved. Can you please test
the `/auloop` command on your device with the sample rates listed in
auloop.c:
```
static const struct {
uint32_t srate;
uint32_t ch;
} configv[] = {
{ 8000, 1},
{16000, 1},
{32000, 1},
{44100, 1},
{48000, 1},
{ 8000, 2},
{16000, 2},
{32000, 2},
{44100, 2},
{48000, 2},
};
```
Did all the tests and audio was OK at all rates and ch counts.
Based on source code of auloop module, it is possible to also set
auloop_codec in config file. Will try that next.
…-- Juha
|
Forgot to mention that when I compile opus lib, I get this kind of note:
CC src/opus_decoder.lo
src/opus_decoder.c:37:10: note: #pragma message: You appear to be compiling without optimization, if so opus will be very slow.
# pragma message "You appear to be compiling without optimization, if so opus will be very slow."
^
I searched the net and got the impression that the note is nothing to
worry about, since the optimization only applies to x86 architecture.
…-- Juha
|
juha-h writes:
Based on source code of auloop module, it is possible to also set
auloop_codec in config file. Will try that next.
I added to the config
auloop_codec OPUS/48000/2
and run auloop:
05-13 13:13:52.319 27349 27366 D Baresip : Audio-loop started: 44100Hz, 2ch
05-13 13:13:53.757 27349 27349 D Baresip : processing command 'auloop'
05-13 13:13:53.757 27349 27366 D Baresip : auloop: could not find codec: OPUS/48000/2
05-13 13:13:53.838 27349 27366 D Baresip : Audio-loop: 48000Hz, 2ch
05-13 13:13:53.867 27349 27366 D Baresip :
05-13 13:13:53.867 27349 27366 D Baresip : Audio-loop started: 48000Hz, 2ch
48000Hz 2ch S16LE n_read=1156 n_write=1292 rw_ratio=0.89 codec='OPUS/48000/2'
48000Hz 2ch S16LE n_read=1166 n_write=1302 rw_ratio=0.89 codec='OPUS/48000/2'
...
48000Hz 2ch S16LE n_read=4060 n_write=4196 rw_ratio=0.96 codec='OPUS/48000/2'
48000Hz 2ch S16LE n_read=4070 n_write=4206 rw_ratio=0.96 codec='OPUS/48000/2'
05-13 13:14:26.508 27349 27349 D Baresip : processing command 'auloop'
Voice quality was much better in the loop than in actual call to another
baresip, where voice is sounds broken.
…-- Juha
|
I did a test using the NDK: r16b The result is good audio, no crackling. The Baresip output is here:
|
Alfred E. Heggestad writes:
I did a test using the `aufile` module as audio input, reading from a
WAV file, excluding errors in the opensles driver.
NDK: r16b
API: 21
Device: Samsung J5
Opus: version 1.2.1
The result is good audio, no crackling.
I can try that too. Would it be possible for me to try with your
libopus.a?
…-- Juha
|
it is possible that the opus encoder is using too much CPU. if this happens couple of more things to try:
|
Alfred,
Since opus audio is fine when I tried with your libopus.a, I started the
make process from scratch in order to find out if I had changed
something in the Makefile. I also downloaded android-ndk-r16b.
The result was that opus does not compile:
make[3]: Entering directory '/usr/src/baresip-android/opus-1.2.1'
CC celt/bands.lo
CC celt/celt.lo
In file included from celt/celt.c:48:0:
celt/float_cast.h:129:10: error: #warning "Don't have the functions lrint() and lrintf ()." [-Werror=cpp]
#warning "Don't have the functions lrint() and lrintf ()."
^
celt/float_cast.h:130:10: error: #warning "Replacing these functions with a standard C cast." [-Werror=cpp]
#warning "Replacing these functions with a standard C cast."
^
cc1: all warnings being treated as errors
It does compile when I'm using the ndk that comes with Android Studio.
So perhaps the whole mess is caused by ndk in Android Studio (which I
assumed is r16).
Anyway, how did you overcome the above compilation error? Have you
added some extra CFLAGS to your Makefile?
…-- Juha
|
juha-h writes:
It does compile when I'm using the ndk that comes with Android Studio.
So perhaps the whole mess is caused by ndk in Android Studio (which I
assumed is r16).
Anyway, how did you overcome the above compilation error? Have you
added some extra CFLAGS to your Makefile?
Alfred,
I added -Wno-error flag to the opus section of Makefile and was able to
build libopus.a. Then I gave it a try in my Android app and the result
was that opus audio worked fine!
So this whole mess was caused by the NDK bundled in Android Studio.
Thanks for your help. I'll close this issue.
…-- Juha
|
Opus audio quality is good when the lib is built using android-ndk-r16b instead of the ndk bundled in Android Studio. |
In my tests, opus coded voice quality has been very bad. Receiving opus audio works fine, but opus audio that baresip sends out is badly broken. I'm using opus_bitrate 28000.
Both G711 and G7221 work fine both ways so looks like the problem is not in opensles driver, but in opus codec itself.
Has anyone else observed this or is it only me or my devices (Anrdoid 5.1 and 7.1.1)? Any hints on how to find the cause the problem?
The text was updated successfully, but these errors were encountered: