Skip to main content

Notice

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: Why doesn't opusenc have a quality setting? (Read 10682 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Why doesn't opusenc have a quality setting?

Why doesn't opusenc have a quality setting? You can either accept the default quality, or you can set the bitrate, but there's no option to select a quality level. Seems very weird...am I missing something?

(To explain further, 1 channel at 128Kb/s is not the same quality level as 8 channels at 128Kb/s. So, the bitrate option is not a substitute for a quality selection option when encoding mixed sources.)

Re: Why doesn't opusenc have a quality setting?

Reply #1
What would you like a quality setting to mean?  Just be a proxy for some sort of bitrate?  A bitrate per channel?  A whole bunch of different bitrates for mono/speech/couple channels, etc.?  Something even more complex aiming for a level of transparency for each track?  There is a default bitrate and you can set a different one if you want.  The default is different per single channel or coupled pair, so reasonably scalable.

It is worth noting that giving a VBR bitrate to opusenc effectively is a quality setting.  Rather than produce output with that bitrate, it will encode with parameters that it knows on average will give that bitrate for a track, but those parameters on your track may use a considerably lower or higher bitrate to hopefully get a similar level of transparency.

Re: Why doesn't opusenc have a quality setting?

Reply #2
Developers just haven't gotten around to it.
have a "constant quality" mode so e.g. mono speech and 5.1 surround fullband music can be encoded with the same settings and be expected to achieve similar quality (quality as measured by e.g. ABC/HR, MUSHRA, etc). Opus devs have in the past talked about this as "fullband stereo equivalent bitrate."
Still under consideration, though not so high on the priority list.
This is unfortunate; even outside of surround sound situations there would be benefits of having such a mode. The VBR scheme has not really sufficed to avoid the fact that opusenc --bitrate XX will yield rather different subjective quality on mono speech vs stereo music. But being paid by Mozilla and working hard on the AV1 video format mean that time spent on Opus is limited and somewhat more directed towards WebRTC and other streaming use cases rather than towards end users encoding at-rest files.

 

Re: Why doesn't opusenc have a quality setting?

Reply #3
Quality? You mean bitrate per channel/couple right?

If you're worried about surround quality, here's a cool thing you should know about opus: there's a lot of techniques for optimizing stereo and surround inside opus that have been in development since the vorbis era, and they're pretty good. You can check a demo with some of it here and see that bits are only allocated where needed. (This is a demo of 1.1, we are currently on 1.3 and there are also other cool demos from newer versions on this same website)

Also, if 256 kb/s is enough for encoding good ambisonics that take way more channels than common surround, I wouldn't worry that much about it.  :D

Re: Why doesn't opusenc have a quality setting?

Reply #4
Quality? You mean bitrate per channel/couple right?

Ideally, bitrates that yield somewhat consistent subjective quality across audio formats (mono, stereo, 5.1, etc).

But I would settle for a really simple, dumb bitrate-per-channel option (like the default 64/96...just let me pick a different number). Opusenc doesn't even have that.

Re: Why doesn't opusenc have a quality setting?

Reply #5
C:\Program Files (x86)\Codecs>opusenc /?
Encoding options:
 --bitrate n.nnn    Set target bitrate in kbit/s (6-256/channel)
 --vbr              Use variable bitrate encoding (default)
 --cvbr             Use constrained variable bitrate encoding
 --hard-cbr         Use hard constant bitrate encoding

Re: Why doesn't opusenc have a quality setting?

Reply #6
I appear to be the only one who made a good faith attempt to understand what was being asked before leaping in with an irrelevant answer.

There's a clear difference between "quality" - measurable by e.g. ABC/HR, MUSHRA, etc - and either bitrate or bitrate per channel/pair. A 7.1 surround file at 80kbps will score much lower in subjective testing than a stereo file at 80kbps; you're throwing a lot more information away and will have more artifacts. A 7.1 surround file at 400kbps - which is 80kbps per channel/pair (three paired, center, LFE) will score higher than a stereo file at 80kbps; there are correlations, masking effects, etc which make it so 7.1 doesn't demand the bitrate of 5 stereo tracks.

Opus devs know this perfectly well, as their past statements about "fullband stereo equivalent bitrate" show.

If you stick to music with the same number of channels, the idea that bitrate is a perfect alias for quality is close enough to true, because that's what the VBR allocation does. If you have a mix of music and speech and/or a mix of channel counts, you're going to have to classify your tracks according to those distinctions and specify a different bitrate for each class. This can be a pain, and a real quality option - again, you could call it a "fullband stereo equivalent bitrate option" if that tickles your fancy- would be a boon.

Re: Why doesn't opusenc have a quality setting?

Reply #7
Caring about evaluating bitrates is annoying if you just want to have an ensured good-balanced output (bits<>transparency).
If it's music only, then it might be a bit more simple, but mixed content and more then 2 channels?
Forget it. It might also never give you the potential and gain you are aiming at.
Therefore people invented vbr and a quality-setting, to get the feature of variability/dynamic and something that expresses your demand/intent/purpose.
If so it definitely makes sense to ask this question.
Opus got a detector, but maybe jmvalin might spend a note to that question.

Re: Why doesn't opusenc have a quality setting?

Reply #8
The only thing hard coded into the encoder and decoder is the resampling quality, which is set at 5. I have made custom builds with this number changed to 10. I don't think the developers will change this behavior soon as they think that 5 is enough, but still internally at the code, it can go up to 10.

Re: Why doesn't opusenc have a quality setting?

Reply #9
The only thing hard coded into the encoder and decoder is the resampling quality, which is set at 5. I have made custom builds with this number changed to 10. I don't think the developers will change this behavior soon as they think that 5 is enough, but still internally at the code, it can go up to 10.
Any chance of getting a 32-bit build of this package?

Re: Why doesn't opusenc have a quality setting?

Reply #10
If it worries you, resample with SoX or something similar before encoding, but I've certainly not been able to detect any difference between quality setting 5 and 10.

Re: Why doesn't opusenc have a quality setting?

Reply #11
And don't forget that the noise level introduced by using lower quality levels with the speex resampler are probably completely dashed apart by what the Opus codec does to the signal.

Re: Why doesn't opusenc have a quality setting?

Reply #12
Higher resampling quality means higher latency, probably an issue for Opus devs.  Probably not an issue for most people reading this.  Not that quality 5 should be anything other than transparent anyway.

Re: Why doesn't opusenc have a quality setting?

Reply #13
Yo, thanks to all for your comments.  I was just curious as to if I would notice anything different, like I guess KozmoNaut was when he tried it.  Doesn't appear I would have  :)

Re: Why doesn't opusenc have a quality setting?

Reply #14
Opus works very well encoding multichannel audio at low bitrates.  I have encoded Pink Floyd's Dark Side of the Moon in 5.1 using Opus at 128 and 160 kbps and there is really very little difference between the low bitrates and going to 256kbps.  Opus is able to use the channels to mask lower bitrates.

Re: Why doesn't opusenc have a quality setting?

Reply #15
Just my .02 about the resampler… This thread should explain a bit ;)
sox -e float -b 32 -V4 -D gain -3 rate -v 48000 norm -1
opusenc --bitrate 128

Re: Why doesn't opusenc have a quality setting?

Reply #16
Here is a bash-script hack to add a --quality n option, where positive n increases quality (in fact, bitrate) and negative n decreases it.
Code: [Select]
#!/bin/bash
set -e

opusenc=/usr/bin/opusenc

args=()
quality=0
while [ $# -gt 0 ]; do
  case "$1" in -q|--quality) shift; quality=$1;; --bitrate) br_given=1;& *) args+=("$1");; esac
  shift
done

if [ "$quality" != 0 ]; then
  test  "$br_given" = 1 && { echo give at most one bitrate/quality option; exit 1;}
  bitrate=`$opusenc ${args[*]} 2>&1|tr ' ' '\n'|grep kbit/sec|head -1|sed 's/k.*//'`
  bitrate="--bitrate `awk "BEGIN{print $bitrate*2^($quality/4)}"`"
fi
$opusenc $bitrate ${args[*]}

Re: Why doesn't opusenc have a quality setting?

Reply #17
Here is a bash-script hack to add a --quality n option, where positive n increases quality (in fact, bitrate) and negative n decreases it.
That doesn't accomplish anything. The point of a quality option rather than just using a bitrate is that you may want to achieve the same perceived quality on vastly different samples: mono speech, standard stereo music, and 5.1 or 7.1 or Ambisonic surround.

Re: Why doesn't opusenc have a quality setting?

Reply #18
The point of a quality option rather than just using a bitrate is that you may want to achieve the same perceived quality on vastly different samples: mono speech, standard stereo music, and 5.1 or 7.1 or Ambisonic surround.
Correct, and I also see this as a bit of an oversight. However, adding a perceived-quality weighting system isn't exactly part of the original goal of Opus. Opus was intended as a low-latency codec, that turned out to be incredibly good overall.

I believe it's just a matter of time, though. If enough people are interested in implementing perceived-quality selectors, someone will eventually put this either into the library, or perhaps into opusenc.

As a full-time software developer, I can't be bothered to read through the code and start working on it either, but I'm sure there are a large number of people willing to invest their time into extending the encoder.