In The Wild with 5,382 Active Installs
In the wild — RAG Converter uses rusty_flac to decode the audio.
It makes personal and work files AI-readable without them leaving the machine:
the whole conversion runs as WebAssembly in the browser tab, with nothing
uploaded and nothing to install.
rusty_flac
rusty_flac is a ground-up, pure-Rust FLAC encoder and decoder:
no required dependencies, no C, no FFI, no_std + alloc ready. It
encodes 17% faster and decodes 23%
faster than FFmpeg while producing smaller files on every benchmarked
content class — and every stream is verified losslessly interoperable in
both directions (FFmpeg decodes ours bit-exact; we decode FFmpeg's
bit-exact). The four SIMD kernels are the only unsafe in the crate, and
each one is gated bit-identical against the scalar twin it ships with.
Part of Remade With Rust by
Mata Network — the FLAC codec inside
remade_ffmpeg_rs,
our memory-safe FFmpeg alternative, alongside
FFAI, the AI media toolkit.
Jump to the ecosystem ↓
⚡ The headline
A pure-Rust lossless audio codec that beats the C reference on speed and
compression at the same time, without giving up a byte of interoperability:
0.3.0: about half the instructions per encode, 9-12% fewer per decode.
Encode at levels 5 and 8 is 39-44% faster than 0.2.2 at 44.1 kHz and 33-40%
at 96 kHz on the wall clock, and 15-bit LPC coefficients cut level-8 output
by 3.2%. Twenty of the speed wins are byte-identical, each confirmed on
the wall clock. Against libFLAC 1.5.0
(flac), whole process including file I/O: level 8 encodes 2.4x faster at
44.1 kHz and 3.9x faster at 96 kHz, level 5 matches its speed with smaller
output at 44.1 kHz, and decode is 16% faster at 16-bit (details below).
Faster than FFmpeg on both sides (measured at 0.2.2; 0.3.0 is faster
still). Encode at the maximum compression level ran 0.83× FFmpeg's CPU
time (17.3% faster); decode 0.77× (22.7% faster). Measured pinned,
CPU-time, ABBA-interleaved, 31 pairs — 31/31 wins on both, z = 5.57
(method below).
Smaller output on every gate clip. Across the standing gate matrix
(music / sine / noise / pink noise / silence × 16-bit and 24-bit × two
levels), rusty_flac's files are smaller than FFmpeg's on 20 of 20
combos — −0.4…−4.6% on real music, −87% on silence.
Lossless and interoperable, proven both directions. Every gate clip
round-trips bit-exact: FFmpeg decodes our streams to the exact source PCM,
and we decode FFmpeg's streams to the exact source PCM. STREAMINFO carries
the spec's MD5 signature, so flac -t verifies our output too.
No required dependencies. No C, no FFI — the bit I/O, CRCs,
MD5, LPC analysis, Rice coding and all four stereo modes are in this crate.
unsafe is confined to runtime-detected AVX2/BMI2 kernels (autocorrelation,
windowing, Rice sums and planning, fixed-order estimation, LPC residual and
restore, Rice reading and writing), each with a portable twin kept as oracle
and fallback and gated bit-identical by tests, plus a few writes into
reserved buffers with their initialization proven at the site. On any other
CPU you get the same bytes.
|
FFmpeg flac (C) |
rusty_flac (Rust) |
| C/C++ in the dependency tree |
all of it |
none |
| Dependencies |
libavcodec/libavutil |
none required (optional pure-Rust libm for no_std) |
| Encode CPU (level 8) |
1.00× |
0.83× — 17.3% faster |
| Decode CPU |
1.00× |
0.77× — 22.7% faster |
| Output size, 20-combo gate matrix |
baseline |
smaller on 20/20 |
| Lossless interop |
— |
both directions, bit-exact, gated |
| License |
LGPL/GPL |
Apache-2.0 (embed freely) |
Performance (single core, this machine)
0.3.0 against libFLAC 1.5.0 (flac, the C reference), 60 s of stereo
guitar at 44.1 kHz/16 and its 96 kHz/24 render. Whole process for both,
including file read, write and the STREAMINFO MD5; interleaved, pinned to
one core, best of 18 (the host was busy, so medians are not quoted). Every
output is checked: our streams pass flac -t, and our decode matches
flac -d byte for byte.
| workload |
rusty_flac 0.3.0 |
flac 1.5.0 |
time |
size vs flac |
| Encode 44.1 kHz/16, level 8 |
88.9 ms |
215.2 ms |
0.41x (2.4x faster) |
+1.2% |
| Encode 44.1 kHz/16, level 5 |
79.4 ms |
85.9 ms |
0.92x |
-0.1% |
| Encode 96 kHz/24, level 8 |
256.0 ms |
1,006.6 ms |
0.25x (3.9x faster) |
+4.0% |
| Encode 96 kHz/24, level 5 |
243.3 ms |
230.2 ms |
1.06x |
+1.3% |
| Decode 44.1 kHz/16 |
45.9 ms |
54.6 ms |
0.84x |
|
| Decode 96 kHz/24 |
143.4 ms |
144.3 ms |
0.99x |
|
0.3.0 against 0.2.2 (same files): encode at levels 5/8 executes
-48.0% / -51.6% instructions at 44.1 kHz and -45.5% / -45.6% at
96 kHz (callgrind, deterministic), and runs 39% / 44% and 40% / 33%
faster on the wall clock (pinned, interleaved, best of 25). Decode executes
-9% on flac -8 streams and -12% on flac -5 streams. What changed
is in the changelog.
FFmpeg 8.1.2, measured at 0.2.2:
Measured against FFmpeg 8.1.2's native flac encoder/decoder over a 180 s
44.1 kHz stereo music clip (guitar / piano / vocal corpus):
| workload |
rusty_flac |
FFmpeg |
ratio |
Encode, -compression_level 8 |
672 ms |
813 ms |
0.83× — 31/31 wins, z = 5.57 |
| Decode (FFmpeg-encoded stream) |
266 ms |
344 ms |
0.77× — 31/31 wins, z = 5.57 |
Size at matched level, the standing gate table (excerpt):
| clip |
level |
rusty_flac |
FFmpeg |
delta |
| stereo guitar (s24) |
L8 |
539,087 |
565,122 |
−4.6% |
| stereo piano (s16) |
L8 |
334,330 |
346,299 |
−3.5% |
| pink noise (s24) |
L8 |
1,057,412 |
1,065,512 |
−0.8% |
| vocal (s16) |
L8 |
839,291 |
847,315 |
−0.9% |
| silence (s16) |
L8 |
1,173 |
9,137 |
−87.2% |
Method (the discipline is the point): both binaries pinned to one
core at High priority, measuring CPU time not wall (a busy box counts
descheduled time against wall), arms ABBA-alternated, 31 pairs, reported
as a paired win-rate with a z-score. Work parity is checked (both arms code
the identical PCM; outputs are verified lossless before anything is timed),
and a null arm (FFmpeg vs itself) bounds the noise floor. Cross-implementation
ratios are quoted at N = 31 because smaller N provably drifts — an earlier
N = 15 read of the same quantity moved 5 points by N = 31.
Where the speed comes from (each brick landed byte-identical or
size-gated): an accumulator bit writer and table CRCs; cached apodization
windows; an exact bottom-up sum-merged Rice partition planner (O(15n) once,
replacing a 15-parameter scan per partition per order); estimate-gated
realization — fixed order by one-pass |residual| sums, window winner by
Levinson estimate, stereo mode by per-arm estimates, with safety margins that
realize runners-up when estimates are close (total size cost of all gating:
+0.09%, still below FFmpeg); exact AVX2 kernels with bit-identity gate
tests; an unrolled MD5; a word-at-a-time bit reader with fused Rice reads; and
pre-sized write-by-index decode buffers.
On a microcontroller (ESP32-S3, no_std)
The same encoder runs on an ESP32-S3 (240 MHz Xtensa LX7, no f64 hardware)
with default-features = false, features = ["libm"]. These are one-block
16 kHz mono streams (4,096 samples) of fixed PCM, measured on a Seeed XIAO
ESP32-S3:
|
0.1.3 |
0.2.0 |
| encode, level 0 |
~124 ms |
~15 ms |
| encode, level 8 |
~169 ms |
~20 ms (loud content ~26 ms) |
| peak heap, 8,192-sample stream |
193–209 KB |
124 KB (140 KB worst case) |
| faster than real time, 16 kHz mono |
2.4–4.3× |
10–17× |
The 0.1.3 row is the Janus team's microphone measurement; the 0.2.0 row
comes from the retired-instruction and cycle counters over fixed PCM. Details
and every step are in
docs/plans/esp32-encoder-cost.md.
What changed:
- The windows are a static table. The full-block window is 5.7 KB of
Q15 in flash, so there is no per-stream cosine work.
- The LPC autocorrelation is exact integer arithmetic. On a chip it was
57–78 % of the encode as soft-float calls; it is now native 32×32→64
multiplies, and the result is identical on every platform.
- The largest scratch buffers are shared between analysis stages, and
sized to the signal.
- Chunked streams can reuse one encoder with
Encoder::finish_and_reset.
- Long streams encode in constant memory with
Encoder::take_frames:
60 s of 48 kHz stereo peaks at the same 167 KB as 5 s (tests/peak_heap.rs).
What is this?
rusty_flac encodes and decodes FLAC in pure Rust — the full subset in both
directions: FIXED and LPC prediction (orders to 12), all four stereo modes
(independent, left/side, right/side, mid/side), wasted-bits detection,
Rice and Rice2 partitioned residuals with escape codes, 8/16/24/32-bit
encode and 4–32-bit decode, up to 8 channels, CRC-8/CRC-16 verification, and the
STREAMINFO MD5 audio signature. There is no C in the dependency tree — the
only dependency is optional and pure Rust (libm, for no_std builds). It
is a reimplementation of the
format, not a wrapper, and it is Apache-2.0: embed it in closed-source
software with no copyleft obligations.
Correctness is enforced by a standing gate matrix, not by hope: every content
class × bit depth × channel count × compression level must round-trip exactly
through two independent decoders (our own and claxon), and the FFmpeg
interop gate proves both encode and decode against the reference in both
directions. The gates found real bugs before release — a spec-invalid
STREAMINFO on sub-16-sample streams and a missing Rice2 path among them —
which is exactly what they are for.
The Remade With Rust ecosystem
Remade With Rust is an initiative by Mata Network
to rebuild essential C and C++ tools in Rust — for the memory safety, the
predictable performance, and the freedom of a permissive license. Each project
is a reimplementation, not a fork: same wire protocols and file formats, new
code you can actually depend on.
We build the core to production grade and open-source it so the community can
extend it. No copyleft. No surprises. Just the tools we rely on, made faster and
safer.
| Project |
What it is |
| 🎬 remade_ffmpeg_rs |
Our FFmpeg alternative. Drop-in ffmpeg and ffprobe binaries — demux → decode → filter → encode → mux, rebuilt as composable Rust crates with zero GPL/LGPL. Apache-2.0. rusty_flac is its FLAC codec. |