DEV Community

Random Dev zzzzz
Random Dev zzzzz

Posted on

vlac: A lossless audio codec for voice, written in Rust

vlac: A lossless audio codec for voice, written in Rust

I built vlac, a lossless audio codec designed specifically for 16kHz mono voice audio. It uses an Order-4 LPC predictor and Zstandard with trained dictionaries.

It's written in Rust for memory safety.

How it works

  1. Predict the next sample using the previous three.
  2. ZigZag encode the residuals.
  3. Split the residuals into High and Low bytes (so Zstandard can compress the zero-padded High bytes efficiently).
  4. Compress with Zstandard.

Benchmarks

On a 10.75-second voice memo (337 KB WAV):

  • Original WAV: 337 KB
  • FLAC (ffmpeg default): 151 KB
  • vlac: 163 KB

vlac currently produces files 8% larger than FLAC on general voice audio. However, it is 100% bit-perfect (verified via MD5 hash on the raw PCM data) and compiles to WebAssembly. The architecture allows for domain-specific dictionary training, which FLAC cannot do.

Repo: https://github.com/pngz-dev/vlac.git

Top comments (0)