Skip to main content


Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Opusenc's built-in resampler (Read 28918 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: Opusenc's built-in resampler

Reply #50
Thank you Octocontrabass, that clears it up for me

Re: Opusenc's built-in resampler

Reply #51
Also, technically, it's not libopus that does the resampling, but the encoder frontend that utilizes libopus. Technically, one could make a more restrictively licensed equivalent of opusenc that uses a different resampler. But again, more restrictive license.

The speex resampler, which is used by opus tools, is technically sufficient for the job anyway, and as you found, quality loss is more likely to be caused by reducing the bitrate than from using a particular resampler.

I should also note, all encoders which mostly fixed the gapless encoding issue, also make use of appropriate padding mechanisms, and work together with the built-in resampler, to minimize effects on the start and end samples of the input data.

The opusenc official encoder includes the encoding resampler's delay in its delay calculations, and pads the input data with a linear predictor, designed to guess what the sample data would be beyond the ends of the input, rather than padding with just silence, so that the ends will hopefully match up when decoded.

This mechanism is different from MP3 and AAC encoders which usually just pad with silence, because those also usually just pad the beginning by a whole "frame", which is usually sufficient to prime the encoder. I do not know if this would have been sufficient for Opus, but for Vorbis, the padding is possibly not to an even packet of input data, and it was probably found that padding with silence didn't yield sufficient results.

Re: Opusenc's built-in resampler

Reply #52
Thanks for the explanation Kode.

Interestingly (for some) I did a quick trial to see what the tangible difference were between using an external resampler (SSRC) and allow OPUS to do it's thing. I didn't listen to the files, because I think that would be futile however...

Both had the same bitrate, 130kpbs (I'd selected 128kbps), however the version resampled with SSRC was about 1kB smaller, and a single sample smaller. There was no difference in encode time on my 12 year old rig.

Re: Opusenc's built-in resampler

Reply #53
Even some of the "bad" resamplers seen on that one site (, you may note from the colors used for the graphs, that at least in a lot of them, the visible aliasing is well below -96 dBA. Accurate is quite important for editing and mastering, but it's probably acceptable to have inaudible aliasing when only applying the result for listening purposes, or encoding into a lossy format which is sure to have way more destruction on the audio quality than the resampler ever will.

Re: Opusenc's built-in resampler

Reply #54
Today I was preparing a lossless audiobook for lossy conversion and out of curiosity I tried something I don't usually do: opusenc in.wav out.opus. You can clearly hear that the sound became sharper. But why, is it the internal resampler?

Code: [Select]
$ mediainfo penguin.flac
Complete name                            : penguin.flac
Format                                   : FLAC
Format/Info                              : Free Lossless Audio Codec
File size                                : 55.5 KiB
Duration                                 : 2 s 0 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 227 kb/s
Comment                                  : Processed by SoX

Format                                   : FLAC
Format/Info                              : Free Lossless Audio Codec
Duration                                 : 2 s 0 ms
Bit rate mode                            : Variable
Bit rate                                 : 227 kb/s
Channel(s)                               : 1 channel
Channel layout                           : M
Sampling rate                            : 32.0 kHz
Bit depth                                : 16 bits
Compression mode                         : Lossless
Stream size                              : 55.3 KiB (100%)
Writing library                          : libFLAC 1.4.3 (2023-06-23)
MD5 of the unencoded content             : 8EF803F2F8C39B34A69197E56DA68EC3

$ mediainfo penguin.opus
Complete name                            : pengiun.opus
Format                                   : Ogg
File size                                : 12.4 KiB
Duration                                 : 2 s 7 ms
Overall bit rate                         : 50.8 kb/s
Writing application                      : opusenc from opus-tools 0.2-34-g98f3ddc

ID                                       : 3623 (0xE27)
Format                                   : Opus
Duration                                 : 2 s 7 ms
Channel(s)                               : 1 channel
Channel layout                           : M
Sampling rate                            : 32.0 kHz
Compression mode                         : Lossy
Writing library                          : libopus 1.5.1, libopusenc 0.2.1-16-ge4285b5

$ opusenc in.wav out.opus
Encoding using libopus 1.5.1 (audio)
   Input: WAV, 32 kHz, 1 channel, mono
  Output: Opus, 1 channel (1 uncoupled), mono
          20ms packets, 49 kbit/s VBR
 Preskip: 312

Encoding complete
       Encoded: 2.02 seconds
       Runtime: 0 seconds
         Wrote: 12734 bytes, 101 packets, 5 pages
       Bitrate: 46.3802 kbit/s (without overhead)
 Instant rates: 30 to 59.2 kbit/s
                (75 to 148 bytes per packet)
      Overhead: 8.03% (container+metadata)
• Join our efforts to make Helix MP3 encoder great again
• Opus complexity & qAAC dependence on Apple is an aberration from Vorbis & Musepack breakthroughs
• Let's pray that D. Bryant improve WavPack hybrid, C. Helmrich update FSLAC, M. van Beurden teach FLAC to handle non-audio data

Re: Opusenc's built-in resampler

Reply #55
I don't have the best hearing anymore but I don't notice any sharpness increase. Though the original has very sharp attacks at the beginning of the words. If there was something going on in the background the sudden impulse would effectively mask that for me.

Anyway, Speex resampler is transparent so it's very unlikely that it has caused any issues you may detect.

But if you wanted to prove everyone wrong, you could use for example SoX at best quality to resample the file to 48 kHz before encoding. If you can ABX the difference then it would prove the resampler isn't transparent.

What do you use to play the opus? Officially it is 48 kHz after encoding but some frontends will resample it back to original 32 kHz.
To have a fair comparison you should play them both at the same samplerate. I'd use 48 kHz, but you can also resample the opus output back to 32 kHz with known good resampler.

Re: Opusenc's built-in resampler

Reply #56
Today content is recorded at 48kHz, this way you get the best performance on the worst hardware. One reason is that the oscillator is an exact multiple of 48kHz, but that's not the only reason.

I'm going to sleep now, you'll ruin my sleep in the future :)

My tests with the latest version: