pdeljanov / Symphonia

Pure Rust multimedia format demuxing, tag reading, and audio decoding library
Mozilla Public License 2.0
2.28k stars 133 forks source link

"buffer underrun" when reading m4a file #311

Open zhaih opened 3 weeks ago

zhaih commented 3 weeks ago

Hi there, I'm using following code to read a file

    let file = Box::new(File::open(Path::new(filename)).unwrap());

    let mss = MediaSourceStream::new(file, Default::default());

    let hint = Hint::new();

    let format_opts: FormatOptions = Default::default();
    let metadata_opts: MetadataOptions = Default::default();

    let probed = symphonia::default::get_probe()
        .format(&hint, mss, &format_opts, &metadata_opts)             <--- error thrown this line
        .unwrap();

    probed.format

And got this error

called `Result::unwrap()` on an `Err` value: IoError(Custom { kind: UnexpectedEof, error: "buffer underrun" })

After some research I found it should be thrown from BufReader, but I don't know what it is reading when throwing this error, please help take a look. I would probably also try to attach a debugger to see what's going on later maybe. I could also share the audio file but since it's purchased so I guess better share it privately.

zhaih commented 3 weeks ago

Ok, I think it's because the genre tag is written in an invalid format, it's expecting an u16 number but the file somehow stored a utf-8 space charactor. But still I think there might be some room of improvement:

  1. Maybe we should ignore the invalid input as long as it doesn't affect actual data integrity?
  2. maybe we can add better debug info on where it fails, rather than having to attach the debugger?