HydrogenAudio

Lossy Audio Compression => Opus => Topic started by: darkbyte on 2017-02-06 19:25:10

Title: Does pre-encode lowpass hurt audio quality of Opus?
Post by: darkbyte on 2017-02-06 19:25:10
I'm evaluating Opus for internet radio purposes (@72kbps and @160kbps) and wondering if feeding a 16kHz lowpassed signal to the encoder would give worse, same or better quality than encoding a full band 20kHz signal? The lowpass actually comes from my multiband compressor and i don't really like to keep content above 16kHz because it seems that >16kHz content may stear the multiband compressor away (some EDM have loud signals in that region).
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: saratoga on 2017-02-07 01:34:24
I really doubt it matters. Lossy encoders rarely devote many bits to high frequencies anyway.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: mpuzirew on 2017-02-07 02:14:44
Lossy encoders rarely devote many bits to high frequencies anyway.
Hmm... For example, FDK AAC (VBR) bitrate varies considerably depending on bandwidth settings in encoder. Moreover, when feeding lowpassed signal to FDK (on maximum vbr5 setting, and with no bandwidth parameter specified), bitrate drops similarly, too.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: jmvalin on 2017-02-07 03:22:14
I'm evaluating Opus for internet radio purposes (@72kbps and @160kbps) and wondering if feeding a 16kHz lowpassed signal to the encoder would give worse, same or better quality than encoding a full band 20kHz signal? The lowpass actually comes from my multiband compressor and i don't really like to keep content above 16kHz because it seems that >16kHz content may stear the multiband compressor away (some EDM have loud signals in that region).
Low-passing is very unlikely to give better result, but it *probably* won't be much worse either. I've never actually experimented with that, so you should just try and see for yourself.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: ziemek.z on 2017-02-07 07:40:45
I'm evaluating Opus for internet radio purposes (@72kbps and @160kbps) and wondering if feeding a 16kHz lowpassed signal to the encoder would give worse, same or better quality than encoding a full band 20kHz signal? The lowpass actually comes from my multiband compressor and i don't really like to keep content above 16kHz because it seems that >16kHz content may stear the multiband compressor away (some EDM have loud signals in that region).
Low-passing is very unlikely to give better result, but it *probably* won't be much worse either. I've never actually experimented with that, so you should just try and see for yourself.
When I was feeding Opus at quite low bitrate with lowpassed signal, Opus treated high frequencies badly. If the lowpass frequency didn't match Opus encoding bands' transition, the encoder produced synthetic high-frequency content up to fullband that wasn't in the original signal.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: jmvalin on 2017-02-07 17:39:23
When I was feeding Opus at quite low bitrate with lowpassed signal, Opus treated high frequencies badly. If the lowpass frequency didn't match Opus encoding bands' transition, the encoder produced synthetic high-frequency content up to fullband that wasn't in the original signal.
Do you have an example signal (with command-line option) that demonstrates that problem?
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: mpuzirew on 2017-02-07 18:45:22
When I was feeding Opus at quite low bitrate with lowpassed signal, Opus treated high frequencies badly. If the lowpass frequency didn't match Opus encoding bands' transition, the encoder produced synthetic high-frequency content up to fullband that wasn't in the original signal.
I can confirm something like this. Here is http://storage8.static.itmages.com/i/17/0207/h_1486492111_5644539_531084a2c8.png the spectrogram of an opus-file at 70 kbps VBR, encoded in foobar2000 with sox-lowpass filter at 16 kHz http://storage8.static.itmages.com/i/17/0207/h_1486492496_8085833_5d1bb7ef27.png
Some kind of high freq "artifacts" are clearly seen on the spectrogram. And interestingly, they disappear (or become hardly noticeable) on upper bitrates (180 or smth.).
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: ziemek.z on 2017-02-07 19:17:56
When I was feeding Opus at quite low bitrate with lowpassed signal, Opus treated high frequencies badly. If the lowpass frequency didn't match Opus encoding bands' transition, the encoder produced synthetic high-frequency content up to fullband that wasn't in the original signal.
I can confirm something like this. Here is http://storage8.static.itmages.com/i/17/0207/h_1486492111_5644539_531084a2c8.png the spectrogram of an opus-file at 70 kbps VBR, encoded in foobar2000 with sox-lowpass filter at 16 kHz http://storage8.static.itmages.com/i/17/0207/h_1486492496_8085833_5d1bb7ef27.png
Some kind of high freq "artifacts" are clearly seen on the spectrogram. And interestingly, they disappear (or become hardly noticeable) on upper bitrates (180 or smth.).
This is exactly what I meant. 16 kHz lowpass isn't perfectly matching Opus band encoding scale. Lowpass should be something about 15 kHz, 15500 Hz or something like this - I don't know Opus' specs perfectly so I can't tell accurate border between two bands, so lowpass was spectrograph-supported trial-and-error guessed.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: ziemek.z on 2017-02-07 19:43:32
When I was feeding Opus at quite low bitrate with lowpassed signal, Opus treated high frequencies badly. If the lowpass frequency didn't match Opus encoding bands' transition, the encoder produced synthetic high-frequency content up to fullband that wasn't in the original signal.
Do you have an example signal (with command-line option) that demonstrates that problem?
Yes, this is an example from my New Matura Success Upper Intermediate CD rip. Original is MP3@128kbps, lowpassed at 16 kHz, along with a transcode to Opus@14kbps VBR, encoded with Opus 1.2 beta and corresponding Speks.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: jmvalin on 2017-02-07 20:59:22
Yes, this is an example from my New Matura Success Upper Intermediate CD rip. Original is MP3@128kbps, lowpassed at 16 kHz, along with a transcode to Opus@14kbps VBR, encoded with Opus 1.2 beta and corresponding Speks.
Well one obvjous issue in the example you posted is the very strong 16 kHz tone in the original. Not sure where that's from, but Opus is definitely not going to like it when all you give it is 14 kb/s. At that rate, there's no way you're going to get good quality music, no matter how you filter.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: darkbyte on 2017-02-07 21:36:41
Yes I have a very similar experience. I thought it's related to some kind of clipping or resampling, but then it comes from the nature of the codec.

So Opus uses an artifical band above 15.8kHz (according to my spectrum; at least on mid and low range bitrates), and if source is lowpassed at 16kHz it puts some kind of signal derived from that tiny 200Hz signal portion up to 20kHz. This is possibly masked by the <15.8kHz content but I don't like it. The best would be to just say, don't encode anything in that band, but there's no such option at the moment. (i'm encoding the same stream for mobile and the higher bitrate for headphone and home listening) I would like to keep audio up to 16kHz for the higher bitrate setting. So it's a bit of a give or take.

Though i have to say I can't seem to hear any audible issues with the 72kbps stream encoded from the lowpassed signal, so it's probably a matter of paranoia :D
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: ziemek.z on 2017-02-07 21:58:41
Yes I have a very similar experience. I thought it's related to some kind of clipping or resampling, but then it comes from the nature of the codec.

So Opus uses an artifical band above 15.8kHz (according to my spectrum; at least on mid and low range bitrates), and if source is lowpassed at 16kHz it puts some kind of signal derived from that tiny 200Hz signal portion up to 20kHz. This is possibly masked by the <15.8kHz content but I don't like it. The best would be to just say, don't encode anything in that band, but there's no such option at the moment. (i'm encoding the same stream for mobile and the higher bitrate for headphone and home listening) I would like to keep audio up to 16kHz for the higher bitrate setting. So it's a bit of a give or take.

Though i have to say I can't seem to hear any audible issues with the 72kbps stream encoded from the lowpassed signal, so it's probably a matter of paranoia :D
This is exactly what I have noticed :) IMHO encoder should be smarter and if it sees that frequencies exist TINY above band transition frequency, those frequencies are quite QUIET and they're not tonal (just MUSICAL NOISE), it should reject them instead of reserving a band for them.

Well one obvjous issue in the example you posted is the very strong 16 kHz tone in the original. Not sure where that's from, but Opus is definitely not going to like it when all you give it is 14 kb/s. At that rate, there's no way you're going to get good quality music, no matter how you filter.
Yes, the 16 kHz tone isn't helping the encoder, but that's NOT the main issue, but the improper handling of lowpassed signals with cutoff slightly above Opus band. Darkbyte and I explained that above.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: jmvalin on 2017-02-07 22:32:07
So Opus uses an artifical band above 15.8kHz (according to my spectrum; at least on mid and low range bitrates), and if source is lowpassed at 16kHz it puts some kind of signal derived from that tiny 200Hz signal portion up to 20kHz. This is possibly masked by the <15.8kHz content but I don't like it. The best would be to just say, don't encode anything in that band, but there's no such option at the moment. (i'm encoding the same stream for mobile and the higher bitrate for headphone and home listening) I would like to keep audio up to 16kHz for the higher bitrate setting. So it's a bit of a give or take.
This is not exactly what's happening. Opus indeed divides the audio into bands, the last of which starts at 15.6 kHz (of course, it's not a brick wall transition). When it does the bit allocation, there's sometimes just not enough bits for the higher bands. It may just be the very last band that doesn't get bits allocated to it, or (at very low rates), it could be all the bands above 8 kHz (there are four). When there's no bits, the best solution is to code the energy of that band and then just "make up" the details, rather than not coding anything. That's part of how Opus manages to sound better than MP3, Vorbis and AAC-LC at low bitrates (despite Vorbis and AAC having a huge advantage in terms of transform size). Even in the "corner case" of a low-pass signal, even though the spectrogram may look strange (extending the noise), I don't think it leads to actually audible artefacts. If you can find a signal where the Opus file *sounds* noticeably better when filtering the original at (e.g.) 15 kHz than at 16 kHz, then please post the original and I'll have a look at it.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: ziemek.z on 2017-02-07 22:33:32
If you can find a signal where the Opus file *sounds* noticeably better when filtering the original at (e.g.) 15 kHz than at 16 kHz, then please post the original and I'll have a look at it.
Same recording, but with sinc-lowpass@15kHz applied with SoX. Sounds better without these ugly high-frequency artifacts :)
And... ABX result ;) (I don't want to violate TOS#8):
Code: [Select]
foo_abx 2.0.2 report
foobar2000 v1.3.13
2017-02-07 23:32:09

File A: New Matura Success UI Wbk T05-no-sox-lowpass.opus
SHA1: 1cd4d01806184957a8d2b59c2b0bf049c26e981e
File B: New Matura Success UI Wbk T05-15kHz-sox-lowpass.opus
SHA1: d46ff697a0877c17991e96ad4bc24ea55f076e6d

Output:
DS : Primary Sound Driver
Crossfading: NO

23:32:09 : Test started.
23:32:22 : 01/01
23:32:29 : 02/02
23:32:39 : 03/03
23:32:48 : 04/04
23:32:57 : 05/05
23:33:10 : 06/06
23:33:25 : 07/07
23:33:43 : 08/08
23:33:49 : 09/09
23:33:51 : 10/10
23:33:56 : 11/11
23:33:58 : 12/12
23:34:01 : 13/13
23:34:05 : 14/14
23:34:09 : 15/15
23:34:09 : Test finished.

 ----------
Total: 15/15
Probability that you were guessing: 0.0%

 -- signature --
cc67e7dae19dca11e46b895dacbd86db278044b3
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: jmvalin on 2017-02-07 23:05:02
Same recording, but with sinc-lowpass@15kHz applied with SoX. Sounds better without these ugly high-frequency artifacts :)
And... ABX result ;) (I don't want to violate TOS#8):
Actually, can you find an example without that strange HF tone? Otherwise it's really hard to know whether the difference is from the "made up" 16-20 kHz band or just from getting rid of that tone (which is also going to cause problems at low rate no matter what). In general, if I'm going to spend time getting rid of an artefact it's both more useful and easier when it's something relatively common (e.g. some mainstream music filtered in condition X) than the combination of a strange signal (e.g. this tone around 16 kHz) in a strange (e.g. this low-pass) condition.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: ziemek.z on 2017-02-08 08:45:09
Same recording, but with sinc-lowpass@15kHz applied with SoX. Sounds better without these ugly high-frequency artifacts :)
And... ABX result ;) (I don't want to violate TOS#8):
Actually, can you find an example without that strange HF tone? Otherwise it's really hard to know whether the difference is from the "made up" 16-20 kHz band or just from getting rid of that tone (which is also going to cause problems at low rate no matter what). In general, if I'm going to spend time getting rid of an artefact it's both more useful and easier when it's something relatively common (e.g. some mainstream music filtered in condition X) than the combination of a strange signal (e.g. this tone around 16 kHz) in a strange (e.g. this low-pass) condition.
I found some Creative Commons Music in MP3@128kbps. I reencoded it to Opus@48kbps. Same thing happens, but it's not annoying due to higher bitrate used.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: jmvalin on 2017-02-08 16:44:04
I found some Creative Commons Music in MP3@128kbps. I reencoded it to Opus@48kbps. Same thing happens, but it's not annoying due to higher bitrate used.
You mean that the MP3 you're including is the input signal you're giving to the encoder? Also, what do you mean exactly by "it's not annoying due to higher bitrate used"? As I pointed out earlier, what I was looking for is samples for which applying a low-pass at a lower frequency (e.g. 15 kHz) ends up sounding better with Opus than applying a low pass at a higher frequency (e.g. 16 kHz) or no lowpass at all.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: ziemek.z on 2017-02-13 19:49:45
You mean that the MP3 you're including is the input signal you're giving to the encoder? Also, what do you mean exactly by "it's not annoying due to higher bitrate used"? As I pointed out earlier, what I was looking for is samples for which applying a low-pass at a lower frequency (e.g. 15 kHz) ends up sounding better with Opus than applying a low pass at a higher frequency (e.g. 16 kHz) or no lowpass at all.
I've got shorter sample without strong HF tone. And... I couldn't find any difference between normally encoded Opus and encoded after lowpassing even when I crossfaded tracks in foo_abx! Another mystery for me is: why LOWPASSED track is BIGGER than normally encoded? I thought that the lowpassed one should be smaller because of lesser value of data to encode... :o I also found WavPack'ed version of the lowpassed track bigger than original.
BTW I've included an MP3 version of the track which is at 14 kbps too, because I can :) Kind of quick comparison between MP3 and Opus ;)
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: jmvalin on 2017-02-14 07:28:13
I've got shorter sample without strong HF tone. And... I couldn't find any difference between normally encoded Opus and encoded after lowpassing even when I crossfaded tracks in foo_abx! Another mystery for me is: why LOWPASSED track is BIGGER than normally encoded? I thought that the lowpassed one should be smaller because of lesser value of data to encode... :o
My best guess as to why the band-limited signal encodes to a larger file is that it may cause the encoder to think that the band just before the low-pass is more important than it really is.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: ziemek.z on 2017-02-14 09:24:20
Another mystery for me is: why LOWPASSED track is BIGGER than normally encoded? I thought that the lowpassed one should be smaller because of lesser value of data to encode... :o
My best guess as to why the band-limited signal encodes to a larger file is that it may cause the encoder to think that the band just before the low-pass is more important than it really is.
I think that dealing with lowpassed signals in opusenc should be improved a bit.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: saratoga on 2017-02-14 18:55:07
If you used an audio editor for lowpass it could also be due to additional dither/truncation noise when converting the lowpass signal back to 16 bit pcm.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: ziemek.z on 2017-02-14 22:00:12
If you used an audio editor for lowpass it could also be due to additional dither/truncation noise when converting the lowpass signal back to 16 bit pcm.
Everything was done in 32-bit float, even feeding the opusenc.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: jmvalin on 2017-02-15 00:41:23
I think that dealing with lowpassed signals in opusenc should be improved a bit.
Improved how? You just said you couldn't hear a difference. If there's an actual artefact that should be removed I may be able to do something about it, but if it's only "this spectrogram looks wrong [but it's inaudible]", it's not good reason to change anything.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: ziemek.z on 2017-02-15 08:48:24
I think that dealing with lowpassed signals in opusenc should be improved a bit.
Improved how? You just said you couldn't hear a difference. If there's an actual artefact that should be removed I may be able to do something about it, but if it's only "this spectrogram looks wrong [but it's inaudible]", it's not good reason to change anything.
I thought about edge cases like that with annoying HF tone, but usually... Opus works well with lowpassed signals :)
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: ziemek.z on 2017-02-15 16:10:29
I'm evaluating Opus for internet radio purposes (@72kbps and @160kbps) and wondering if feeding a 16kHz lowpassed signal to the encoder would give worse, same or better quality than encoding a full band 20kHz signal? The lowpass actually comes from my multiband compressor and i don't really like to keep content above 16kHz because it seems that >16kHz content may stear the multiband compressor away (some EDM have loud signals in that region).
Low-passing is very unlikely to give better result, but it *probably* won't be much worse either. I've never actually experimented with that, so you should just try and see for yourself.
So, here's an answer to your question, darkbyte. If it sounds good, there's no problem, just enjoy the music :) I've found Opus-encoded lowpassed content not so problematic, so don't worry, be happy.
Title: Re: Does pre-encode lowpass hurt audio quality of Opus?
Post by: butrus on 2017-04-10 21:08:18
I think that dealing with lowpassed signals in opusenc should be improved a bit.
Improved how? You just said you couldn't hear a difference. If there's an actual artefact that should be removed I may be able to do something about it, but if it's only "this spectrogram looks wrong [but it's inaudible]", it's not good reason to change anything.

Hi jmvalin!
What about having an additional option to opusenc, let's say "--assume-lowpassed 16000" which would help the encoder make better decisions (e.g. not creating bigger files...)?
SimplePortal 1.0.0 RC1 © 2008-2021