Skip to content
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

Closed
juha-h opened this issue May 11, 2018 · 15 comments
Closed

opus codec bad voice quality #20

juha-h opened this issue May 11, 2018 · 15 comments

Comments

@juha-h
Copy link
Collaborator

juha-h commented May 11, 2018

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?

@juha-h
Copy link
Collaborator Author

juha-h commented May 11, 2018

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.

@juha-h
Copy link
Collaborator Author

juha-h commented May 13, 2018

I also tried with speex codec and again voice quality was fine. So it is only opus that has the issue.

@alfredh
Copy link
Collaborator

alfredh commented May 13, 2018

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},
};

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)

Alfred

@juha-h
Copy link
Collaborator Author

juha-h commented May 13, 2018 via email

@juha-h
Copy link
Collaborator Author

juha-h commented May 13, 2018 via email

@juha-h
Copy link
Collaborator Author

juha-h commented May 13, 2018 via email

@juha-h
Copy link
Collaborator Author

juha-h commented May 13, 2018 via email

@juha-h
Copy link
Collaborator Author

juha-h commented May 13, 2018 via email

@juha-h
Copy link
Collaborator Author

juha-h commented May 13, 2018 via email

@alfredh
Copy link
Collaborator

alfredh commented May 13, 2018

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.

The Baresip output is here:

shell@j5xnlte:/data/local/tmp $ ./baresip                                      
baresip v0.5.9 Copyright (C) 2010 - 2018 Alfred E. Heggestad et al.
Local network address:  IPv4=:10.0.0.104 
aucodec: opus/48000/2
auplay: opensles
ausrc: opensles
ausrc: aubridge
auplay: aubridge
ausrc: aufile
medianat: stun
medianat: turn
medianat: ice
Populated 1 account
Populated 2 contacts
Populated 1 audio codec
Populated 0 audio filters
Populated 0 video codecs
Populated 0 video filters
baresip is ready.
android@10.0.0.4: {0/UDP/v4} 200 OK (callflow v0.1.0 (arm6/linux)) [1 binding]
All 1 useragent registered successfully! (14 ms)
answering call from sip:aeh@10.0.0.4 with 200
audio: Set audio decoder: opus 48000Hz 2ch
audio: player started with sample format S16LE
audio: Set audio encoder: opus 48000Hz 2ch
aufile: loading input file 'lr.wav'
aufile: lr.wav: 48000 Hz, 2 channels
aufile: audio ptime=20 sampc=1920 aubuf=[192000:3840000]
aufile: end of file
aufile: loaded 7442240 bytes
audio: source started with sample format S16LE
audio tx pipeline:      aufile ---> opus
audio rx pipeline:    opensles <--- opus
stream: incoming rtp for 'audio' established, receiving from 10.0.0.109:11546
android@10.0.0.4: Call established: sip:aeh@10.0.0.4
aufile: end of file34/31320 (bit/s)    
aufile: player thread exited
sip:android@10.0.0.4: Call with sip:aeh@10.0.0.4 terminated (duration: 39 secs)

audio           Transmit:     Receive:
packets:           1951         1888
avg. bitrate:      32.2         31.5  (kbit/s)
errors:               0            0
pkt.report:        1754         1694
lost:                 0           15
jitter:             2.3          3.6  (ms)
Quit
ua: stop all (forced=0)
Stopping 1 useragent.. 

@juha-h
Copy link
Collaborator Author

juha-h commented May 13, 2018 via email

@alfredh
Copy link
Collaborator

alfredh commented May 13, 2018

it is possible that the opus encoder is using too much CPU. if this happens
the whole audio input will be blocked, leading to lost PCM samples inside Baresip.

couple of more things to try:

  • After running a call for >10 seconds press A to see the audio debug
    (pay attention to transmit aubuf and overruns/underruns)

  • Test again with aufile module and run Baresip with -v, using this commit:

baresip/baresip@ce3d2ae

  • Try audio_txmode thread

@juha-h
Copy link
Collaborator Author

juha-h commented May 13, 2018 via email

@juha-h
Copy link
Collaborator Author

juha-h commented May 13, 2018 via email

@juha-h
Copy link
Collaborator Author

juha-h commented May 13, 2018

Opus audio quality is good when the lib is built using android-ndk-r16b instead of the ndk bundled in Android Studio.

@juha-h juha-h closed this as completed May 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants