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: Changing Opus default bitrate (Read 13085 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Changing Opus default bitrate

Hi,

I'm looking for a way to change the default bitrate for Opus. Can someone please tell me which files need to be edited in the source to compile an executable with the new default values?

My intention is to raise them (64kbps mono / 96kbps coupled) "just to be sure" as I'm about to batch encode the audio tracks of my movie collection since I need to remux them anyway. I've been using -V 91 with the Apple encoder (QAAC) and it gives somewhat larger bitrates than Opus at default values.

Changing Opus default bitrate

Reply #1
opusenc.c
Code: [Select]
/*Lower default rate for sampling rates [8000-44100) by a factor of (rate+16k)/(64k)*/
    bitrate=((64000*header.nb_streams+32000*header.nb_coupled)*
             (IMIN(48,IMAX(8,((rate<44100?rate:48000)+1000)/1000))+16)+32)>>6;


This seems like the bit that sets the defaults.
"I hear it when I see it."

Changing Opus default bitrate

Reply #2
Thanks, I'll try that out

Changing Opus default bitrate

Reply #3
Hold up a sec... You want to modify source code and recompile, but you don't want to pass a command line argument to a utility?  Is this because you're dealing with both stereo and mono input?

Changing Opus default bitrate

Reply #4
Hold up a sec... You want to modify source code and recompile, but you don't want to pass a command line argument to a utility?  Is this because you're dealing with both stereo and mono input?
That is my problem - I'm dealing with material ranging from mono to 5.1 channels.

I've not yet succeeded in compiling Opus as it requires ogg. I have put libogg-1.3.2 in the include folder of my MSYS installation but no luck. Googling things doesn't reveal anything useful to me since I'm much of a beginner what comes to compiling stuff.

Changing Opus default bitrate

Reply #5
If you don't know how to compile a program, you may be biting off more than you can chew to modify it.  Still, there's always a time to learn

libogg-1.3.2 sounds like the executable portion of the library to me.  The include files for compiling against the library would be a separate package (called something like libogg-dev in Linux), and that is what you need before you can compile opus.  You might need other stuff too.

Changing Opus default bitrate

Reply #6
Okay, I think I see what's going on here.  The reference Vorbis encoder (oggenc) uses a quality setting that scales your bitrate accordingly, but the Opus reference encoder doesn't have this.

Changing Opus default bitrate

Reply #7
This is definitely about learning 

I did manage to install ogg (had to compile and then install, learnt something about the package stuff along the way), now it shows with pkg-config --list-all. However, configure halts because it cannot detect opus:

checking for OGG... yes
checking for OPUS... no
configure: error: Package requirements (opus >= 1.0.3) were not met:

Requested 'opus >= 1.0.3' but version of Opus is unknown
You may find new versions of Opus at http://opus-codec.org/

pkg-config shows this:

$ pkg-config --list-all
liblzma    liblzma - General purpose data compression library
libarchive libarchive - library that can create and read several streaming archi
ve formats
openssl    OpenSSL - Secure Sockets Layer and cryptography libraries and tools
guile-1.8  GNU Guile - GNU's Ubiquitous Intelligent Language for Extension
libcrypto  OpenSSL-libcrypto - OpenSSL cryptography library
opus      Opus - Opus IETF audio codec (floating-point build)
libxml-2.0 libXML - libXML library version2.
zlib      zlib - zlib compression library
autoopts  AutoOpts - A semi-automated generated/library option parser
minizip    minizip - Minizip zip file manipulation library
ogg        ogg - ogg is a library for manipulating ogg bitstreams
libssl    OpenSSL - Secure Sockets Layer and cryptography libraries

I'm getting there but cannot find my way around this.

Changing Opus default bitrate

Reply #8
What are you trying to compile ?

 


Changing Opus default bitrate

Reply #11
Same problem.  When your configure says "checking for...", it means it is checking for the include headers for that library.  In Linux this would be libopus-dev (NOT libopus, that is just the library itself, not the headers).  Look for something similar that contains files like opus.h and opus_types.h.  Then your configure will continue and you'll be able to build.

Building libogg yourself shouldn't be necessary, but the source code for it necessarily contains the headers that you need to compile against that library so it gets you where you need to be.

Changing Opus default bitrate

Reply #12
Quote from: lithopsian link=msg=0 date=
The include files for compiling against the library would be a separate package (called something like libogg-dev in Linux)


Quote from: lithopsian link=msg=0 date=
In Linux this would be libopus-dev (NOT libopus, that is just the library itself, not the headers).


For the sake of accuracy.

Splitting headers is just a packaging policy enforced by some distributions. It has nothing to do with (GNU/)Linux.

Other distributions do their packaging sanely (and as upstream intended). They either never split headers. Or only split them in extreme cases (Boost and its huge headers come to mind).

Changing Opus default bitrate

Reply #13
Other distributions do their packaging sanely (and as upstream intended). They either never split headers. Or only split them in extreme cases (Boost and its huge headers come to mind).

Sanely? What's sane about installing thousands of files only needed for development on every non-developer machine, wasting space, traffic ...
And either do the splitting consistently or let it be.

(For the same reasons it can make sense to split architecture independent data, docs and large debug symbols ...)

"I hear it when I see it."

Changing Opus default bitrate

Reply #14
Same problem.  When your configure says "checking for...", it means it is checking for the include headers for that library.  In Linux this would be libopus-dev (NOT libopus, that is just the library itself, not the headers).  Look for something similar that contains files like opus.h and opus_types.h.  Then your configure will continue and you'll be able to build.

Building libogg yourself shouldn't be necessary, but the source code for it necessarily contains the headers that you need to compile against that library so it gets you where you need to be.
Is there a way to check where it is looking for those? The files are there under my MSYS folder (in c:\utils\msys\include\opus to be exact) as that is where they were installed when I built opus and that is where ogg is as well but that one is found by the configure script. I have tried --PREFIX=c:/utils/msys as a parameter in configure but that doesn't help.

Changing Opus default bitrate

Reply #15
configure: error: Package requirements (opus >= 1.0.3) were not met:

Requested 'opus >= 1.0.3' but version of Opus is unknown

These lines clearly show where the configure script failed.
You need opus >= 1.0.3 but "pkg-config --version opus" didn't return a sane version number for some reason
(The result of pkg-config --list-all show that you actually have opus installed).
You can examine $prefix/lib/pkgconfig/opus.pc, but probably you have to re-install opus (maybe by building opus yourself).

Changing Opus default bitrate

Reply #16
Thanks, I'll check that. I did build and install opus beforehand but maybe something went wrong there.

I got one step forward before I got off to work; I took a look at the config.log and noticed some empty environment variables related to paths to the various required packages. I set the Opus-related variables according to what the paths are in my MSYS installation - which configure should automatically pick as it already picks Ogg - and then got past that one. The next error was that FLAC is not installed, which is correct as I had not yet done that.

So maybe it is just that the Opus version is not returned or parsed correctly?

Changing Opus default bitrate

Reply #17
I had the same problem on linux when I installed opus from git.

Find the opus pkgconfig file itself. In linux it's called opus.pc and located in a folder named pkgconfig.

In that file there's a line starting "Version:" . Yours will say "unknown" . Change it to "1.1" .

Changing Opus default bitrate

Reply #18
I had the same problem on linux when I installed opus from git.

Find the opus pkgconfig file itself. In linux it's called opus.pc and located in a folder named pkgconfig.

In that file there's a line starting "Version:" . Yours will say "unknown" . Change it to "1.1" .

That's it! Incredibly frustrating and silly, but that's it 

I ran into the next problem while trying to make, but I'll try to figure it out myself first. I have a feeling that my MSYS installation is not proper in some way. Actually I didn't install it but got it from XhmikosR's site - works fine for x264 or x265 though.

Changing Opus default bitrate

Reply #19
The next issue proved to be bigger than me, so I need to bother you again.

Configure runs fine now, but make fails: I get the dreaded error "conflicting types for 'ssize_t'". I don't have the exact error message here right now, but it seemed that in some .h it was declared as int and in some as long.

Is this a problem with the sources or my MSYS environment? I'm afraid this might be off topic here but since we're talking about compiling, and maybe it helps someone else too..

Changing Opus default bitrate

Reply #20
I do not understand your problems.
MSYS on Windows? Just grab pkg-config from gtk.org, extract to /usr/local
Code: [Select]
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig; tar xf opus-1.1.tar.gz; cd opus-1.1; ./configure; make; make check; make install


Do the same for opus-tools-0.1.9. If it requires other libraries then either get them and do the same as above or disable them with ./configure --without-flac for example. See the last page of ./configure --help

Worked for me in a few minutes.
"I hear it when I see it."

Changing Opus default bitrate

Reply #21
I'm not able to make it work.

Here's what I've done:

(Downloaded XhmikosR's MSYS package from http://xhmikosr.1f0.de/tools/msys/)

1) Unpack MSYS to c:\ so it's at c:\msys
2) Run pi.bat and entered path to MinGW as c:/msys/mingw
3) Run msys.bat
4) cd /c/sources/libogg-1.3.2
5) ./configure --prefix=/c/msys; make; make install
6) cd ..
7) cd opus-1.1.1-beta
8) ./configure --prefix=/c/msys; make; make install
6) cd ..
7) cd opus-tools-0.1.9
8) ./configure --prefix=/c/msys --without-flac; make; make install

After that last make statement (not make install), I get a bunch of errors regarding some conflicting types.

I added the config.log here since it will probably show what the real problem is. There are quite a few warnings there but they are not shown in the console during configure.

I'm probably doing something wrong but I'm too confused to know what at this point.

[attachment=8162:config.zip]

Changing Opus default bitrate

Reply #22
If you are seriously trying to cross-compile using mingw, you're gonna have a bad time.

Changing Opus default bitrate

Reply #23
(Downloaded XhmikosR's MSYS package from http://xhmikosr.1f0.de/tools/msys/)

Why?
But anyway, even this version of msys works fine here.

Where did you get your mingw? What's your gcc version? What does
Code: [Select]
make check
tell you for opus-1.1?

1) Unpack MSYS to c:\ so it's at c:\msys
2) Run pi.bat and entered path to MinGW as c:/msys/mingw

Usually it's the other way around, i.e. msys is under mingw, but it shouldn't matter since msys.bat mounts the mingw path.

5) ./configure --prefix=/c/msys; make; make install

Why the weird prefix? Do you really want to install stuff into the msys root? At least use /usr, but I'd stick with what I posted above.
Why don't you export the PKG_CONFIG_PATH if you use a nonstandard location?

After that last make statement (not make install), I get a bunch of errors regarding some conflicting types.

edit: fix your pkg-config path problems and you should be fine
"I hear it when I see it."

Changing Opus default bitrate

Reply #24
If you are seriously trying to cross-compile using mingw, you're gonna have a bad time.

There is no cross-compilation here, but even so it does work very well. I've "recently" cross-compiled 64-bit mpv a couple of times successfully.
"I hear it when I see it."