RustAudio/lewton

Song lenght

portaloffreedom opened this issue · 1 comments

Is there a way to calculate the lenght of the song without decoding it all?
I found this: https://stackoverflow.com/questions/34981079/duration-of-audio-file-with-libvorbis-for-android#35484472
but cannot find the number of samples in the api or in the code.

est31 commented

Ogg doesn't explicitly encode the length in samples. Instead, you have to seek to the end of the file and then check the absolute granule pos of the last packet. My ogg_metadata crate has implemented this. You can use it to obtain the length. If you have any issues with usage, please tell me!