Bindings to libopus for the Opus audio codec.
Provides Haskell FFI bindings to libopus, the reference implementation of the Opus Codec (RFC 6716 and RFC 8251). The Opus codec is designed for interactive speech and audio transmission over the Internet, but is also intended for storage and streaming.
The library provides an interface to the encoder and decoder, as well as a Conduit wrapper for operating with stream data.
To use this library, you need to have the libopus library installed on your system. Please see the README for more info.
The compiled Haskell code will link dynamically by default, so if you are distributing a precompiled binary, you may want to look into static linking.
This package is a fork of the original opus package by Markus Barenhoff, which is no longer maintained (and was never published to Hackage). Permission has been granted by the original author to publish this fork with the same name under the BSD3 license.
opus: Haskell Bindings to libopus
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.
Usage
- 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.
Development
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
License
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.