Balrogg losslessly recompresses Ogg Vorbis and Opus audio files

Balrogg losslessly recompresses Ogg Vorbis and Opus audio files

Balrogg, a project by Kamila Szewczyk hosted on GitHub, losslessly recompresses Ogg Vorbis and Opus audio files into its own container format. Archives it produces are typically 8 to 12 percent smaller than the original .ogg (Vorbis) files and 3 to 8 percent smaller than the original .opus files, with the underlying audio reproduced exactly on decode. The project is licensed under GNU GPL version 3, and issues are reported to Szewczyk by email.

The command line takes an action letter plus files: balrogg e music.ogg music.blr encodes, balrogg d music.blr music.ogg decodes, and balrogg detects the codec automatically. Encoding appends a .blr extension; decoding removes it. Passing -b switches to batch mode, where every remaining path is processed in parallel across the available cores and memory, with larger inputs scheduled first; batch mode reports the highest nonzero exit status returned by any single file. A -p or --progress flag shows a progress bar on stderr during encoding and decoding, identifying each Vorbis tuning trial separately, with --progress-lines available for log output and separate labeled lines per file in batch mode.

Compression effort is set with -1 through -9 on the command line, defaulting to -9. Up to -4, each additional level adds a residue-model stage that also affects decoding; from -4 through -9, higher levels only widen the parameter search, so decoding speed stays the same across that range. During Vorbis tuning, balrogg evaluates the entire file at each selected setting and keeps only the best candidate, holding at most that candidate and the current trial in the destination file at once.

The encoder is deliberately strict: it refuses any file it cannot reproduce exactly, including files with bad checksums, invalid page sequences, unsupported Vorbis features, or a missing final end-of-stream page, and a refusal produces a diagnostic message with exit status 1. Vorbis packets carrying extra padding or alternative floor subclass choices still get normal floor and residue compression, with classword corrections and padding modeled separately and shortened, peeled packets handled with an adaptive byte model. Opus support is narrower: balrogg accepts only a single mono or stereo logical stream using channel mapping family 0, with packets, including OpusHead and OpusTags, capped at 61,440 bytes; chained or multichannel Opus files are refused outright.

Each file is processed on a single thread and needs seekable input and output files. On supported hosts, balrogg applies a default 2 GiB process memory cap to reject unreasonable allocations, which can be changed or disabled by setting the BLR_MEMCAP environment variable to a size in MiB or to 0. Resulting archives are portable across hosts. Users can install a prebuilt binary from GitHub Releases or their package manager, or build from source with ./configure, make and sudo make install (running ./bootstrap first from a Git checkout, which needs autoconf and automake); the codebase is written in C99 against only the C and math libraries, with its Opus parser derived from libopus. Cross builds are documented for 64-bit Windows via MinGW, for a Windows 95 target using a small KERNEL32 runtime on i486 with a win95-check verification step, and for MS-DOS via DJGPP on i386 with a DPMI host such as CWSDPMI, where batch mode replaces file extensions and runs serially. Until version 2.0, releases are not backwards or forwards compatible with each other.

Key facts

  • Balrogg losslessly recompresses Ogg Vorbis files to typically 8 to 12 percent smaller than the original, and Opus files to typically 3 to 8 percent smaller.
  • Compression effort is set with -1 through -9 (default -9); levels up to -4 add a residue-model stage affecting decode speed, while -4 through -9 only widen the search and decode equally fast.
  • The encoder refuses to compress any file it cannot reproduce exactly, exiting with status 1 on a bad checksum, invalid page sequence, unsupported Vorbis feature, or missing end-of-stream page.
  • Opus support is limited to a single mono or stereo stream with channel mapping family 0 and packets up to 61,440 bytes; chained or multichannel Opus files are rejected.
  • The project is GPLv3-licensed, written in C99, and ships build instructions for Linux, 64-bit Windows via MinGW, a Windows 95 target, and MS-DOS via DJGPP.

Why it matters

Balrogg targets a narrow but real problem: shrinking already-compressed lossy audio archives further without touching the decoded sound. Ogg Vorbis and Opus are widely used lossy codecs, and most tools that touch a Vorbis or Opus file either re-encode it, losing further quality, or leave it as is. Balrogg instead repacks the existing bitstream into a smaller lossless container, recovering 8 to 12 percent on Vorbis files and 3 to 8 percent on Opus files, which matters for anyone storing large collections of such files at scale.

Who it affects

It is aimed at people and systems that hold large libraries of Ogg Vorbis or Opus audio, such as music archives, game asset bundles, or voice recordings, where a single-digit to low-double-digit percentage saved per file adds up across a collection. It also affects retrocomputing and embedded developers, since the project explicitly documents building for Windows 95 on i486 and for MS-DOS via DJGPP, alongside standard Linux and 64-bit Windows builds.

How to use it

balrogg is invoked as balrogg e input output to compress and balrogg d input output to decompress; it detects the source codec itself, appending .blr on encode and stripping it on decode. The -b flag batch-processes every remaining path across available cores and memory, with larger files scheduled first, and -p/--progress shows a per-trial progress bar (or per-line logs with --progress-lines). Effort is tunable from -1 to -9 (default -9), trading search time for size. Installation is via a package manager or GitHub Releases binaries, or by building from source with ./configure && make && sudo make install (plus ./bootstrap on a fresh Git checkout); it is licensed under GNU GPL version 3.

How solid is it

The encoder is built to refuse rather than risk silent corruption: it will not touch a file it cannot reproduce exactly, rejecting bad checksums, invalid page sequences, unsupported Vorbis features, or a missing end-of-stream page, and signals this with exit status 1 and a diagnostic message (batch mode surfaces the worst status among all processed files). Vorbis handling includes explicit modeling for edge cases like extra padding, alternative floor subclasses, and packet peeling. Each file runs on one thread with seekable input and output required, and a default 2 GiB memory cap (adjustable via the BLR_MEMCAP environment variable) guards against runaway allocation.

Risks and caveats

Compatibility is not yet settled: releases are not backwards or forwards compatible with one another until version 2.0 is reached, so archives made with one version may not decode with another. Opus support is deliberately narrow, covering only a single mono or stereo stream with channel mapping family 0 and packets up to 61,440 bytes, with chained or multichannel Opus files rejected outright. The GPLv3 license also constrains use in closed-source distribution. Beyond the stated percentage ranges, no independent benchmarks, release history, or comparison against other lossless recompressors are given in the source material.