minimp3_fixed

Crates.iominimp3_fixed
lib.rsminimp3_fixed
version0.5.4
sourcesrc
created_at2023-07-25 17:34:44.865488
updated_at2023-07-25 17:40:10.359384
descriptionRust bindings for the minimp3 library. With Security patch applied
homepage
repositoryhttps://github.com/BOB450/minimp3-rs.git
max_upload_size
id925805
size27,778
BOB450 (BOB450)

documentation

README

minimp3 Rust bindings

A fixed non depercated version of minimp3 that applies a vital security patch

Usage example

# Cargo.toml

[dependencies]
minimp3_fixed = "0.5.3"
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),
        }
    }
}
Commit count: 87

cargo fmt