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

Distorted sound in OPUS streams #1459

Closed
ivellios1988 opened this issue Apr 20, 2019 · 21 comments
Closed

Distorted sound in OPUS streams #1459

ivellios1988 opened this issue Apr 20, 2019 · 21 comments
Labels
error An error encountered when running the software. upstream Involves software that is "upstream" from AzuraCast, i.e. broadcasting software or OS software.

Comments

@ivellios1988
Copy link

I noticed strange problem with OPUS streams. There appears a distortion which makes them sound like they were badly resampled from 44100 Hz to 48000 Hz without proper filtering. I recorded a sample to illustrate the issue:

left channel: OPUS 192kbps, 48000 Hz
right channel: MP3 128kbps, 44100 Hz

In the left channel, the distortion is very clearly audible, especially with sibilants.

Untitled Session 2_mixdown.zip

@BusterNeece BusterNeece added the error An error encountered when running the software. label Apr 20, 2019
@BusterNeece
Copy link
Member

@ivellios1988 I'm not sure what's causing the problem here. This may be an upstream issue with Liquidsoap rather than anything with AzuraCast, though it's definitely possible that our settings are causing the problem, in which case we're happy to modify the settings as needed to resolve it.

@BusterNeece BusterNeece added the upstream Involves software that is "upstream" from AzuraCast, i.e. broadcasting software or OS software. label Apr 20, 2019
@ivellios1988
Copy link
Author

Maybe Liquidsoap needs update? Or is it already up-to-date in current version of AzuraCast?

I just did some tests in order to determine of there's anything I can do to fix the issue.

In liquidsoap.liq I changed complexity for my OPUS stream to 0. No success, the distortion still occurred.

Then I did some tests using Web DJ. I've been experimenting with different sample rates, switching from MP3 to raw, changing bitrates, etc. No success, the distortion still occurred.

I remember that I had a similar issue with virtual audio devices in Windows 7/8/10, similar distortion appeared when I tried to send some audio through them. It turned out that the cuplrit was wrong 'internal sampling rate' which was set to 96000 Hz, I had to either change sampling rates in my audio devices to 48000 Hz or change the 'internal sampling rate' to 88200 Hz (or something like that).

@ivellios1988
Copy link
Author

I just did a one more test, this time I was experimenting with changing sample rate in liquidsoap.liq. I changed samplerate from 48000 to 24000, then I changed permissions in order to prevent the file from being overwritten when Liquidsoap is restarted, and I restarted Liquidsoap. Audio bandwidth was cut to 24000 Hz, of course, but the distortion was still there.

@ivellios1988
Copy link
Author

For the purposes of testing various things, I created a station with two streams:

OGG: https://s.paranormalium.pl/radio/8020/ogg

OPUS: https://s.paranormalium.pl/radio/8020/opus

Audio bandwidth of the file being played is 8000 Hz (I attached the original file to this post). In OGG stream the sound is clear, whereas in OPUS stream a heavy distortion is clearly audible.

I also tried playing files with sample rate of 48000, however, no success, the distortion was still present.

speech_16kbps_wb_44100.zip

@BusterNeece
Copy link
Member

@ivellios1988 I'm very confident that this issue is "upstream" from the AzuraCast web interface, and that something in either Liquidsoap or its underlying lib implementation is causing this problem. I would heavily advise that you make an issue reporting these same details over at https://github.com/savonet/liquidsoap

@ivellios1988
Copy link
Author

How to check which version of libopus, libsamplerate and liquidsoap does AzuraCast use?

@Vaalyn
Copy link
Sponsor Member

Vaalyn commented Apr 25, 2019

@ivellios1988 You can see which versions of the packages we install in the Dockerfile of the radio container.

@Vaalyn
Copy link
Sponsor Member

Vaalyn commented May 1, 2019

@ivellios1988 The docker image is now updated to use libopus 1.3.1. Can you update and check if the problem is fixed by that?

@ivellios1988
Copy link
Author

I just updated my AzuraCast installation, then rebooted my server. Unfortunately, however, the distortion is still present. :(

@ivellios1988
Copy link
Author

Just a quick test: opus_test.zip

Artifacts in 'opus' file remind me of the issue some users of Teamspeak had. From what I read on their community forums, the problem was related to framesize being too low which resulted in opus adding some noises to the sound.

@BusterNeece
Copy link
Member

@ivellios1988 I'm actually not sure what our original rationale was for setting the sampling rate for OPUS streams to be 48kHz instead of 44.1kHz, but I've switched it back to the same sample rate used by the other formats. That should fix the issue, but let me know if it doesn't.

@ivellios1988
Copy link
Author

Unfortunately the distortion is still there. I updated my AzuraCast installation and even rebooted my VPS. No success, sound in OPUS is still distorted :(

@ivellios1988
Copy link
Author

I did a couple of tests. I tested AzuraCast on three versions of Ubuntu (16.04 LTS, 18.04 LTS, 19.04). Distortion in OPUS streams was present all the time. I thought the problem may in some way be related to version of Ubuntu but it turned out that's not the case.

It seems to me that the sound sent to OPUS encoder is already distorted.

By the way, after the recent update, AzuraCast keeps setting sample rate for OPUS streams to 44100 which results in errors when starting Liquidsoap, and it's necessary to change the sample rate manually in liquidsoap.liq and change permissions to avoid the file being overwritten.

@BusterNeece
Copy link
Member

@ivellios1988 Apparently that's why we set it to 48kHz. Reverting that commit then.

Have you tried modifying the other things that we set on OPUS streams:

%opus(samplerate=44100, bitrate='.$bitrate.', vbr="none", application="audio", channels=2, signal="music", complexity=10, max_bandwidth="full_band"

i.e. changing complexity, max_bandwidth, application, or signal?

BusterNeece added a commit that referenced this issue May 2, 2019
@ivellios1988
Copy link
Author

Already tried that, no success. I even added frame_size with all possible values - still no success, sound is distorted all the time.

@BusterNeece
Copy link
Member

@ivellios1988 Well then I'm even more confident it isn't something we're doing wrong with AzuraCast itself. This is almost 100% likely to be an "upstream" issue from us, likely to do with either the OCaml encoder connector or the encoder itself.

If you haven't already, I'd definitely recommend creating an issue over on Liquidsoap's GitHub page and seeing if they can track down the source of the problem. If you find anything out and there's something that requires our action (i.e. updating our codebase or library dependencies) just let us know.

@ivellios1988
Copy link
Author

There's already an open issue on their GitHub page: savonet/liquidsoap#759

Since streams in other formats work perfectly fine, I'm also sure that there's nothing wrong with AzuraCast.

@Vaalyn
Copy link
Sponsor Member

Vaalyn commented May 3, 2019

I've also done some tests in my dev environment where I could replicate the issue from a bare liquidsoap script that just re-encodes an .mp3 to an opus file, which means it's not the config that AzuraCast generates, it could still be the system setup but it's more likely to be an issue with the upstream software. I added that to the issue over at liquidsoap together with my tests input / output files so that they have something to try to replicate that.

@BusterNeece BusterNeece reopened this May 4, 2019
@BusterNeece
Copy link
Member

@ivellios1988 Our Docker and Ansible scripts have both been updated to incorporate libsamplerate and its OCaml connector; please update and let us know if it helps with the issue.

@ivellios1988
Copy link
Author

I can confirm that the distortion is gone, at last :)

Thank you very much. You're real scientists!

@BusterNeece
Copy link
Member

@ivellios1988 Happy we could help! :)

@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
error An error encountered when running the software. upstream Involves software that is "upstream" from AzuraCast, i.e. broadcasting software or OS software.
Projects
None yet
Development

No branches or pull requests

3 participants