danog / php-rtc-opus
Lazy libopus FFI bindings for PHP audio encoding and decoding. MadelineProto's PHP 8.2+ fork keeps FFI optional within the modular danog/php-rtc stack.
Fund package maintenance!
Requires
- php: ^8.2
- danog/php-rtc-av: ^1.0
- danog/php-rtc-exception: ^1.0
- danog/php-rtc-mixin: ^1.0
Requires (Dev)
- phpunit/php-code-coverage: 11.0.x-dev
- phpunit/phpunit: ^11.3
Suggests
- ext-ffi: Install the FFI extension and libopus to encode or decode Opus; not required to packetize already-encoded Opus
README
Deprecation Notice: This library will be replaced with the AV library in a future update.
A lightweight PHP wrapper for the libopus audio codec using PHP FFI.
This package provides encoder and decoder classes for working with raw PCM audio and the Opus format.
About this fork
This is the danog/php-rtc-opus fork used by MadelineProto. It targets PHP 8.2+, loads and publishes the libopus FFI binding lazily after validating the native library, and therefore does not require FFI merely to install the wider WebRTC stack.
All internal Composer dependencies use their danog/php-rtc-* package names directly, so installing a component selects the maintained danog packages throughout the dependency graph.
Features
- Encode raw PCM audio to Opus format
- Decode Opus-encoded audio back to PCM
- Based on FFI bindings to the native libopus library
- Compatible with multi-channel and variable sample rate audio
Requirements
- PHP ≥ 8.2
- FFI and libopus only when encoding or decoding audio
- Linux environment (Windows/macOS support planned)
Documentation
This package is part of the PHP WebRTC library. For complete documentation, examples, and API reference, visit:
Credits
Authors
-
Amin Yazdanpanah
aminyazdanpanah.com github@aminyazdanpanah.com -
Sana Moniri
GitHub
Reporting Issues
Found a bug? Please report it on our issues.
License
BSD 3-Clause License. See LICENSE for details.