This is an active fork of previous work at alios/opus with permission granted from the original author to publish the package/code under the same name.
Xiph.Org Foundation's Opus Audio codec is a widely used audio codec for VoIP and
streaming. libopus
is the reference implementation of an encoder and decoder
for this codec, and is available to be used via various package managers
under the BSD-3 license.
This Haskell package provides bindings to libopus
's encoding and decoding
functionality. It is continuously tested against the official audio vectors in
the project CI (on GitHub).
The package also provides Conduit functions for encoding and decoding, for easy use in streaming scenarios.
- Add
opus
to your cabal/stack project dependencies - Install
libopus
andpkg-config
(used for finding where libopus is):- On Windows: Run the following commands in your MSYS2 environment:
If you do not know where your MSYS2 environment is, but you installed the Haskell toolchain using GHCup, try:
pacman -S mingw64/mingw-w64-x86_64-pkg-config pacman -S mingw64/mingw-w64-x86_64-opus
ghcup run -m -- pacman -S mingw64/mingw-w64-x86_64-pkg-config ghcup run -m -- pacman -S mingw64/mingw-w64-x86_64-opus
- On MacOS: Run the following commands:
brew install opus
- On Ubuntu/Debian: Run the following commands:
apt-get install pkg-config apt-get install libopus-dev
- On Windows: Run the following commands in your MSYS2 environment:
- Import and get going! For example, import
Codec.Audio.Opus.Encoder
to use theopusEncoderCreate
andopusEncode
functions.
To develop locally, you will need the pkg-config
(pre-installed on Mac) and
libopus
system packages, as described above.
To run tests locally, you will also need the Opus test vectors available within
a directory called opus_newvectors
. The following command will do just that:
curl -L https://opus-codec.org/static/testvectors/opus_testvectors-rfc8251.tar.gz | tar -xz
test/opus_compare.c
was taken as-is from Xiph.Org Foundation under the BSD-3
license.
This project as a whole is licensed under the BSD-3 license. Please see the LICENSE file for more information.
Copyright (c) 2018 Markus Barenhoff
Copyright (c) 2021-2022 Yuto Takano
Copyright (c) 2025-PRESENT Haskell Opus Library Contributors