rff-codec-flac 0.4.2

Remade FFmpeg (Rust): FLAC lossless audio decoder.
Documentation

rff-codec-flac

Remade With Rust By Mata Network License: Apache-2.0

The FLAC lossless audio codec adapter for remade_ffmpeg_rs — decode and encode via our in-house, pure-Rust rusty_flac. No C, no FFI.

  • Streams frame by frame — the decoder takes one FLAC frame per packet (configured from the STREAMINFO in extradata, as the FLAC and Matroska demuxers supply it), so decoding a long file never holds it whole.

  • In-house encoder — LPC prediction, stereo decorrelation, partitioned Rice residual coding and the MD5 signature over the unencoded samples.

  • At parity with FFmpeg's FLAC at -compression_level 8 (within 0.03% on our corpus).

  • Lossless: decode(encode(x)) == x, byte for byte.

  • FLAC is royalty-free.

Usage

use rff_codec::CodecRegistry;
use rff_core::{CodecId, Error};

fn main() -> Result<(), Error> {
    let mut codecs = CodecRegistry::new();
    rff_codec_flac::register(&mut codecs);

    // Now reachable by id or by FFmpeg-style name.
    let _decoder = codecs.find_decoder(CodecId::Flac)?;
    let codec = codecs.by_id(CodecId::Flac).expect("just registered");
    println!("{} — decode: {}, encode: {}", codec.long_name, codec.can_decode(), codec.can_encode());
    Ok(())
}

Part of Remade With Rust

This crate is one layer of remade_ffmpeg_rs — a ground-up, permissively-licensed Rust rebuild of FFmpeg: a drop-in ffmpeg/ffprobe CLI on pure-Rust codecs, with no copyleft. Most users want the remade-ffmpeg engine facade or the rff-cli binaries rather than this crate directly.

Also check out our sister project FFAI — media for an AI-first world — and the rest of github.com/remade-with-rust, including the standalone codec crates rusty_h264, rusty_vp9, rusty_mp3, rusty_aac, rusty-opus, rusty_vorbis, and the rusty-av1-toolkit forks.

About Mata Network

Mata Network builds sovereign, self-hostable infrastructure. Remade With Rust is our open-source home for the permissively-licensed building blocks that work depends on.

License

Apache-2.0. See the workspace LICENSE.