Formats and build
Supported formats, known limitations and build options.
Supported formats
| Codec | Containers |
|---|---|
| MP3 | MP3 |
| AAC-LC | MP4/M4A, ADTS |
| ALAC | MP4/M4A |
| FLAC | FLAC |
| Vorbis | Ogg |
| Opus | Ogg, WebM/Matroska |
| PCM | WAV |
Stage 1 only reads audio. All formats are decoded to f32 PCM.
Known limitations
- HE-AAC. HE-AAC and HE-AACv2 are unsupported. When SBR is signalled
explicitly, opening the file throws
UnsupportedFormatException. Implicit SBR and ADTS HE-AAC cannot be detected when the file is opened, so such a file may decode as its AAC-LC core. - Opus in MP4. Opus in an MP4 container is unsupported in stage 1. Opus in Ogg and in WebM/Matroska is supported.
- WebM tags. WebM gives no tags, because the tag library has no Matroska support. The reported duration may include up to one packet of tail padding.
- m4a and ADTS frame count. For m4a and ADTS files,
totalFramesincludes the 1024-frame AAC priming. It is exact for wav, flac, mp3 with a LAME/Xing header, vorbis, ogg-opus and alac; mp3 without that header is counted from the packets. - ID3v1 text. ID3v1 is decoded as Latin-1, so non-Latin titles in ID3v1-only files (for example CP1251 Cyrillic) show as mojibake. ID3v2 tags are unaffected.
- The
format:hint is advisory. Content detection wins, and a wrong hint is not an error. - Web. See WebAssembly: you supply
frustbite.wasm,*Asyncmethods still run on the main thread, and under dart2wasm with a CSP that forbidsunsafe-evala Rust panic escapes as a raw JavaScript error.
How the native library is obtained
The published package carries the prebuilt library for every native target in
its prebuilt/ directory, and the build hook picks the one for your target.
The build is offline and hermetic: no download, no network access and no Rust
toolchain. Twelve targets are bundled: Android (armv7, arm64, x86_64), iOS
(device, and simulator on arm64 and x86_64), Linux (x86_64, aarch64), macOS
(arm64, x86_64) and Windows (x86_64, arm64).
Every target uses one file name (libfrustbite.so, libfrustbite.dylib or
frustbite.dll), and only the directory, prebuilt/<os>-<arch>[-sim]/, tells
the targets apart. This keeps Flutter from warning about different framework
names per architecture.
Integrity check
prebuilt/checksums.json maps <target>/<file name> to a SHA-256 hash. The
hook hashes the bundled library and refuses to use it when the hash is missing
or differs, with a checksum mismatch error. If you see it, clear the pub
cache entry and reinstall. To check by hand, hash the file with sha256sum
(or shasum -a 256) and compare it with its entry in that JSON.
Binary portability
- Linux binaries are built with
cargo zigbuildagainst glibc 2.17 and link libgcc statically, so they load on glibc-based distributions with glibc 2.17 or newer (CentOS 7 and newer). musl distributions such as Alpine are not supported. - Android libraries are aligned to 16 KB pages.
- Apple libraries have the install name
@rpath/libfrustbite.dylib. - Windows libraries link the C runtime statically, so no Visual C++ Redistributable is needed.
CI checks every library with tool/verify_native.sh before a release.
Choose where the library comes from
Set user defines in your application’s pubspec.yaml. The hook resolves the
library in this order:
library: <path>uses that file as is. It must exist. The file is unchecked: it gets no checksum and no build-time ABI check (only the runtime ABI check at the first call),formatscannot be combined with it, and a relative path resolves against the directory of thepubspec.yamlthat sets the define, not the working directory.sourceis one of:auto(default): the bundled library if there is one, elsecargo buildif the Rust crate and cargo are present, else aStateErrorthat lists these options.prebuilt: only the bundled library. It is an error if it is missing.build: onlycargo build --release --lockedof the Rust crate.none: add no library. The app then fails at its first Frustbite call with the “missing native library” error.
formatsandlocal_build: trueboth meansource: build.
hooks:
user_defines:
frustbite:
library: /opt/frustbite/libfrustbite.so
source also takes a map per OS, with an optional default. The keys are Dart
OS names (android, ios, linux, macos, windows). An unknown key or
value is an error, never a silent auto.
hooks:
user_defines:
frustbite:
source:
default: prebuilt
linux: build
Build from source
Set source: build (or the alias local_build: true) to compile the crate
with Cargo. This needs a Rust toolchain, and it works with the package from
pub.dev: the package carries the crate in rust/. In a repository checkout or
with a git dependency, the hook uses native/. In your application’s
pubspec.yaml:
hooks:
user_defines:
frustbite:
source: build
The hook finds cargo on PATH, then in $CARGO_HOME/bin, then in
~/.cargo/bin, so a Rust installed by rustup works even when your shell
profile is not loaded. The crate pins its toolchain in rust-toolchain.toml,
which rustup installs on the first build. With no cargo and no bundled library
for your target the build fails with an error that names the source options.
Reduce the binary size with formats
By default every codec is compiled in. The formats user define compiles only
the codecs you list, which makes the library smaller. Setting it implies a
source build, so a Rust toolchain is required. Combining it with
source: prebuilt is an error.
hooks:
user_defines:
frustbite:
formats: [mp3, wav]
Supported names: aac, alac, flac, mp3, opus, vorbis, wav. An
unknown name or an empty list fails the build. A source whose codec is not
compiled in throws UnsupportedFormatException when it is opened.