Skip to content

Decoder::new silently zeros data #879

@MAKMED1337

Description

@MAKMED1337

Initial issue is from marin-m/SongRec#263
Related issue: #846

Code to reproduce:

use std::fs::File;
use std::io::BufReader;

fn main() {
    let file = File::open("video.mp4").unwrap();
    let decoder = rodio::Decoder::new(BufReader::new(file)).unwrap();
    let mut count = 0u64;
    let mut nonzero = 0u64;
    for s in decoder {
        count += 1;
        if s != 0.0 { nonzero += 1; }
        if count > 16_000 * 30 { break; }
    }
    eprintln!("[BROKEN]  Decoder::new(BufReader): samples={count} nonzero={nonzero}");

    let decoder = rodio::Decoder::try_from(File::open("video.mp4").unwrap()).unwrap();
    let mut count = 0u64;
    let mut nonzero = 0u64;
    for s in decoder {
        count += 1;
        if s != 0.0 { nonzero += 1; }
        if count > 16_000 * 30 { break; }
    }
    eprintln!("[WORKING] Decoder::try_from:      samples={count} nonzero={nonzero}");
}
[package]
name = "rodio-test"
version = "0.1.0"
edition = "2024"

[dependencies]
rodio = { git = "https://github.com/RustAudio/rodio.git", default-features = false, features = [
    "symphonia-isomp4", "symphonia-aac",
] }

Output:

[BROKEN]  Decoder::new(BufReader): samples=2048 nonzero=0
[WORKING] Decoder::try_from:      samples=480001 nonzero=469761

Works only on git, on the latest release, that is, 0.22.2 the working code is broken (there was a commit that fixed it).

Test file:

video.mp4

LLM yap (may be helpful, IDK):

report.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions