germangb / minimp3-rs

minimp3 rust bindings + wrapper
MIT License
65 stars 20 forks source link

Read frame without decoding it? #41

Open mcclure opened 5 months ago

mcclure commented 5 months ago

I would like to know the number of samples in a file before I decode it (#21). An obvious way to do this would be to iterate over all frames and sum the sample count of each frame. But there is a problem. Iterating over a frame necessarily means decoding the samples. If I want to do one pass getting sample count and a second pass interpreting the sample, I will have to do the mp3 decode twice. This is inefficient.

Would it be possible to get a way to call next_frame() but only get sample_rate, channels etc and not data?