---
title: "Lossless Re-Encoding of Vorbis and Opus Audio Files"
authors:
  - "Kamila Szewczyk"
year: 2026
venue: "arXiv preprint (cs.SD)"
arxiv: "2611.32641"
doi: null
source: "https://arxiv.org/abs/2611.32641"
version_reviewed: "v1"
topics:
  - "lossless-compression"
  - "context-mixing"
  - "entropy-coding"
  - "audio-codecs"
  - "recompression"
seed_rank: 2748
seed_batch: "curiosity-2026-11-29"
reviewed: "2026-11-28"
pool: "systems"
relevance_score: 7
cites:
  - title: "Lossless Re-Encoding of Vorbis and Opus Audio Files"
    url: "https://arxiv.org/abs/2611.32641"
    year: 2026
    arxiv: "2611.32641"
    doi: null
  - title: "Balrogg (source code, GPLv3)"
    url: "https://github.com/iczelia/balrogg"
    year: 2026
    arxiv: null
    doi: null
see: []
---

# Lossless Re-Encoding of Vorbis and Opus Audio Files

## One-sentence takeaway

Balrogg undoes the static entropy coding of Ogg Vorbis and Ogg Opus files and re-codes the same symbols with adaptive context mixing, so the decoder restores the original file bit for bit. At the default level it shrinks Vorbis music by 16.2–21.0%, Vorbis speech by 10.6% and Opus speech by 5.4%, where xz, zstd, ZPAQ and bzip3 save at most 4.1%. It runs symmetrically at 1.8–3.2 MB/s per core in under 12 MiB.

## Why it's lovely

This is packJPG/Lepton for audio, from the author of bzip3. Codecs use deliberately simple entropy coders: static Huffman in Vorbis, fixed-table range coding in Opus, and a uniform distribution for CELT's pyramid-VQ indices. That leaves redundancy any adaptive model can take, and nothing has to be decoded to PCM, because Balrogg parses packets only up to the entropy-coding stage. The details are craft. Vorbis codebook entries become tuples of small signed "digits", binarized in five stages and mixed by an online logistic mixer whose weights are chosen by neighbouring digits and the previous residue pass. Opus symbols use adaptive models seeded with the codec's own tables as priors, with a regret bound. PVQ indices are split recursively into pulse counts without changing the codec's code length. Everything is integer-only, and the format is independent of compiler, word size, byte order and SIMD. The general lesson, take an existing format's symbol stream and swap only the entropy stage, applies to any asset pipeline that ships pre-compressed blobs.

## Key ideas

- **Architecture.** The coder splits Ogg pages into packets and handles three streams: payload symbols (the codec models), container data (residual and byte models), and side information (mispredicted classwords, padding, truncated packets, and Opus bytes that differ from the reference range encoder's output).
- **Vorbis.** A codebook-independent digit representation of residue entries, mixing a direct context model, a bit-history model and a match model.
- **Opus.** Adaptive models with pre-seeded priors and a regret bound (Proposition 1), and a recursive PVQ split that preserves code length for any split tree (Proposition 2).
- **Determinism.** A 32-bit range coder with carry propagation, 16-bit probabilities and integer arithmetic only. The archive stores no model parameters except three tuning bytes.
- **Evaluation.** 48 encoder configurations (libvorbis 1.3.7, libopus 1.5.2 and 1.3.1, FFmpeg 7.1) on the 70 EBU SQAM tracks give 66.5–96.1% of original size, and all 3,360 files were accepted. On random Internet Archive samples (Vorbis files from 17 libvorbis releases, 2001–2020) no file became larger.

## Caveats

This is a single-author v1 preprint, and the measurements refer to Balrogg tag 1.5 (commit c7aedca). Opus gains are modest (5.4% on speech). Files with damaged containers are rejected rather than passed through. Re-encoding is archival or transport-only, since players need the original stream back. I read the abstract, Sections I–II and the results sections, not the full model derivations.

## Links

- arXiv abstract: https://arxiv.org/abs/2611.32641
- PDF: https://arxiv.org/pdf/2611.32641
- Code: https://github.com/iczelia/balrogg
