LibOpus.Interop 0.1.0-dev4

This is a prerelease version of LibOpus.Interop.
dotnet add package LibOpus.Interop --version 0.1.0-dev4
                    
NuGet\Install-Package LibOpus.Interop -Version 0.1.0-dev4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LibOpus.Interop" Version="0.1.0-dev4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LibOpus.Interop" Version="0.1.0-dev4" />
                    
Directory.Packages.props
<PackageReference Include="LibOpus.Interop" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LibOpus.Interop --version 0.1.0-dev4
                    
#r "nuget: LibOpus.Interop, 0.1.0-dev4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LibOpus.Interop@0.1.0-dev4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LibOpus.Interop&version=0.1.0-dev4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=LibOpus.Interop&version=0.1.0-dev4&prerelease
                    
Install as a Cake Tool

LibOpus.Interop

.NET bindings for libopus 1.6: an Opus encoder and decoder for .NET 11 with every control typed, over complete source-generated bindings to the library. libopus ships in the package for Windows, Linux and macOS on x64 and arm64.

  • Encode and decode float, 16-bit and 24-bit PCM at 8 to 48 kHz, mono or stereo, in 2.5 to 120 ms frames.
  • Every control typed: bitrate (changed between frames), complexity, variable or constant bitrate, in-band forward error correction and the loss it is tuned for, discontinuous transmission, signal type, bandwidth, frame duration, prediction, phase inversion, gain.
  • Loss handling: concealment of a lost packet, and recovery of it from the next packet's FEC.
  • Packet inspection from the table of contents: bandwidth, channels, frames, duration, whether FEC is carried.
  • Allocation-free on every encode and decode path; spans in, counts out.
  • Native AOT compatible, with runtime marshalling disabled.

Getting started

dotnet add package LibOpus.Interop
using LibOpus.Interop;

using var encoder = new OpusEncoder(48_000, channels: 2, OpusApplication.Audio)
{
    Bitrate = 96_000,
    InbandFec = OpusInbandFec.On,
    PacketLossPercentage = 10,
};
using var decoder = new OpusDecoder(48_000, channels: 2);

float[] pcm = new float[960 * 2]; // 20 ms, interleaved
byte[] packet = new byte[OpusPacket.MaxFrameBytes];
int length = encoder.Encode(pcm, packet);

float[] decoded = new float[OpusPacket.MaxSamplesPerChannel * 2];
int samples = decoder.Decode(packet.AsSpan(0, length), decoded);

A packet that never arrived is concealed by decoding an empty one, or recovered from the forward error correction the next packet carries:

int recovered = decoder.DecodeForwardErrorCorrection(nextPacket, decoded.AsSpan(0, 960 * 2));

The bindings themselves are in LibOpus.Interop.Native under libopus's own names (Opus.opus_encode, Opus.OPUS_SET_BITRATE_REQUEST), for anything the managed layer does not cover yet; the controls go through Opus.opus_interop_*_ctl*, which are fixed-signature forms of libopus's variadic ones.

Building

See CONTRIBUTING.md: cmake -P eng/build-native.cmake builds libopus from the pinned source, then dotnet build and dotnet test.

License

MIT for this library. libopus is BSD-3-Clause; its license ships in the package as LICENSE.opus.txt.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net11.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on LibOpus.Interop:

Package Downloads
Agash.StreamTransport.Codecs.Opus

Opus audio encoder and decoder for Agash.StreamTransport on libopus (LibOpus.Interop): 20 ms packets with capture timestamps, in-band FEC, live bitrate changes and packet loss concealment, behind the Media audio contracts. Allocation-free per packet.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-dev4 65 11/11/2026
0.1.0-dev3 400 10/28/2026