135.4. opus-1.6.1
Opus audio codec for voice and music
| Version | 1.6.1, release 1 |
| Shelf | audio-codecs — Audio codecs, containers and tagging, including the Bluetooth audio codecs |
| Phase | 41_system (System), 21 of 1047 in build order |
| Licence | BSD-3-Clause |
| Homepage | https://opus-codec.org/ |
| Build time | 0.4 SBU |
| Installed size | 4.9 MiB in 11 files |
| Recipe | ports/core/audio-codecs/opus/kpkgbuild |
About
Opus is the IETF audio codec for speech and music, from narrowband voice to full-band stereo, and the codec of WebRTC calls and of .opus files. This port is the reference library, libopus. pipewire, ffmpeg, the GStreamer plugins, chromium, mumble, freerdp and spice encode and decode through it; libopusenc and opusfile build file writing and reading on top of it.
It is one of the hot libraries the tree builds with link-time optimisation (see Every port).
Why it is in KDOS
The comment above the 5 ports from libogg to lame in script/phases/41_system/packages.d/audio-codecs.txt:
ffmpeg, libsndfile and the gst plugin packages are configured against these and are only as capable as what is installed: each of those build systems answers a missing library by disabling the feature rather than failing. One encoder per format — adding a second earns nothing.
Sources
opus-1.6.1.tar.gz(10.0 MiB)
sha2566ffcb593207be92584df15b32466ed64bbec99109f007c82205f0194572411a1
upstream: https://downloads.xiph.org/releases/opus/opus-1.6.1.tar.gz
archive copy: sources-1/audio-codecs--opus-1.6.1.tar.gz
Dependencies
Depends on: nothing a recipe names.
Required by (32): audacity, avidemux, baresip, chromium, ddnet, ffmpeg, freerdp, gst-plugins-bad, gst-plugins-base, handbrake, ioquake3, kwave, libopusenc, libsndfile, mpd, mumble, musescore, opus-tools, opusfile, pipewire, qt6-qtwebengine, sdl2-mixer, sdl3-mixer, sdrangel, sideband, sox, spice, spice-gtk, termusic, vlc, warzone2100, wireshark.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install opus'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/audio-codecs/opus.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/audio-codecs/opus
echo '6ffcb593207be92584df15b32466ed64bbec99109f007c82205f0194572411a1 opus-1.6.1.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/opus
SRC=$SRC_ROOT/opus-1.6.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf opus-1.6.1.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
export CFLAGS="$CFLAGS -flto=auto -frandom-seed=opus"
export LDFLAGS="$LDFLAGS -flto=auto"
./configure --prefix=/usr --libdir=/usr/lib --disable-static \
--disable-doc \
--disable-extra-programs \
--enable-deep-plc \
--enable-dred \
--enable-osce
make
make DESTDIR=$PKG install
The switches, and why each is set:
-flto=auto— compile and link with link-time optimisation, inCFLAGSandLDFLAGS.-frandom-seed=opus— fix the seed GCC names each object’s.gnu.lto_*sections with, so the objects are the same bytes on every build.--enable-deep-plc— conceal lost packets with a neural network instead of the classic concealment, in SILK frames and in CELT frames alike.--enable-dred— Deep REDundancy: an encoder can add neural redundancy to a stream, from which a decoder rebuilds speech lost in a burst of dropped packets.--enable-osce— enhance low-bit-rate SILK speech in the decoder with a neural network, and build the blind bandwidth extension that widens 16 kHz SILK speech to full band.--disable-doc— with--disable-extra-programs: no API reference and no demo and test programs.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/opus, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf opus-1.6.1-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/opus, and runs the triggers its paths call for.
Contents
Installed libraries: libopus.so.
Installed directories: /usr/share/licenses/opus.
Short descriptions
opus.pc |
Opus IETF audio codec (floating-point build) |
Notes
All three neural features are off by upstream’s default. Their model weights ship in the release archive as C sources under dnn/, so nothing is downloaded; what they cost is the weights’ size in libopus. A caller turns each on: the decoder uses deep PLC from a complexity of 5 and OSCE from 6, both set with OPUS_SET_COMPLEXITY, whose decoder default is 0; the bandwidth extension needs a complexity of 4 and OPUS_SET_OSCE_BWE as well; and the encoder adds DRED only when the caller sets OPUS_SET_DRED_DURATION. A caller that asks for none of them encodes and decodes as it would with a library built without them.