| Crates.io | minimp3 |
| lib.rs | minimp3 |
| version | 0.6.1 |
| created_at | 2018-01-31 18:47:34.717591+00 |
| updated_at | 2025-08-15 13:26:34.689062+00 |
| description | Rust bindings with a high-level wrapper for the minimp3 C library. |
| homepage | |
| repository | https://github.com/germangb/minimp3-rs.git |
| max_upload_size | |
| id | 49059 |
| size | 27,790 |
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.
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.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),
}
}
}
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),
}
}
}