opus-tools icon indicating copy to clipboard operation
opus-tools copied to clipboard

Option to select bitrate based on quality

Open abbrev opened this issue 6 months ago • 0 comments

I added a --quality N option to opusenc.c which automatically selects the bitrate depending on the number of channels in the input file. The quality scale is the same as Vorbis; that is, -2 to 10, with 3 being nearly transparent. With a bit of testing of levels -1 through 2 (I tested with a stock oggenc which doesn't support below -1), I get roughly the same audio quality output as oggenc (of course, Opus requires somewhat lower bitrate than Vorbis for the same quality). At quality level 3 and above I have a hard time distinguishing them from lossless, so there may be room for tuning the bitrates for quality 3 and above.

With this option you can do, for example:

opusenc --quality 3 mono.flac
opusenc --quality 3 stereo.flac
opusenc --quality 3 5.1.flac
opusenc --quality 3 7.1.flac

and get approximately the same audio quality from mono, stereo, and 5.1 or 7.1 surround.

Before I put in more effort to test and polish up my changes, how much real interest is there in this option? I saw some interest at https://hydrogenaud.io/index.php/topic,116997.0.html (and some discussion of bitrate vs quality at https://hydrogenaud.io/index.php/topic,120007.75.html). And I personally like the concept of having one knob to control the quality rather than having to set the bitrate depending on how many channels the input file has (having used Ogg Vorbis a lot in the past, it feels almost natural to me). And how likely is this feature to be merged?

I added this option based on the v0.2 tag, but I noticed that the master branch has changes related to handling channel configurations that affect mine. So I'd have to rebase to master if that's where it needs to go, assuming this gets enough interest.

Edit to add: there's more discussion about bitrate vs quality at https://hydrogenaud.io/index.php/topic,120007.75.html.

abbrev avatar Aug 26 '24 23:08 abbrev