#mp3 #mpeg #audio-decoder #decoder

no-std minimp3

Rust bindings with a high-level wrapper for the minimp3 C library

14 releases

Uses new Rust 2024

0.6.1 Aug 15, 2025
0.5.2 Aug 10, 2025
0.5.1 Jan 2, 2021
0.5.0 Aug 27, 2020
0.1.0 Jan 31, 2018

#30 in Audio

Download history 7388/week @ 2025-12-18 6530/week @ 2025-12-25 6708/week @ 2026-01-01 2760/week @ 2026-01-08 7098/week @ 2026-01-15 7032/week @ 2026-01-22 6517/week @ 2026-01-29 5578/week @ 2026-02-05 5479/week @ 2026-02-12 7664/week @ 2026-02-19 7116/week @ 2026-02-26 10222/week @ 2026-03-05 7400/week @ 2026-03-12 9313/week @ 2026-03-19 8139/week @ 2026-03-26 6934/week @ 2026-04-02

33,062 downloads per month
Used in 35 crates (22 directly)

MIT license

79KB
1.5K SLoC

C 1K SLoC // 0.0% comments Rust 430 SLoC // 0.0% comments Shell 226 SLoC // 0.0% comments

minimp3-rs

Rust bindings with a high-level wrapper for the minimp3 C library.

The build process statically links all C code into the Rust library. There is no need for consumers to provide a library file of minimp3.

CAUTION ⚠️

This crate is not recommended for new projects due to multiple memory unsoundness issues and the availability of mature, safe Rust alternatives. Consider using fully Rust-based libraries instead, such as:

Cargo package Cargo package

Usage example

# Cargo.toml

[dependencies]
minimp3 = "<latest version from crates.io>"
use minimp3::{Decoder, Frame, Error};

use std::fs::File;

fn main() {
    let mut decoder = Decoder::new(File::open("audio_file.mp3").unwrap());

    loop {
        match decoder.next_frame() {
            Ok(Frame { data, sample_rate, channels, .. }) => {
                println!("Decoded {} samples", data.len() / channels)
            }
            Err(Error::Eof) => break,
            Err(e) => panic!("{:?}", e),
        }
    }
}

Async I/O

The decoder can be used with Tokio via the async_tokio feature flag.

# Cargo.toml

[dependencies]
minimp3 = { version = "0.4", features = ["async_tokio"] }

# tokio runtime
tokio = { version = "0.2", features = ["full"] }
use minimp3::{Decoder, Frame, Error};

use tokio::fs::File;

#[tokio::main]
async fn main() {
    let file = File::open("minimp3-sys/minimp3/vectors/M2L3_bitrate_24_all.bit").await.unwrap();
    let mut decoder = Decoder::new(file);

    loop {
        match decoder.next_frame_future().await {
            Ok(Frame {
                   data,
                   sample_rate,
                   channels,
                   ..
               }) => println!("Decoded {} samples", data.len() / channels),
            Err(Error::Eof) => break,
            Err(e) => panic!("{:?}", e),
        }
    }
}

Dependencies

~0.4–1.8MB
~32K SLoC