RustAudio / rodio

Rust audio playback library
Apache License 2.0
1.72k stars 223 forks source link

symphonia impl total_duration #405

Open kamiyaa opened 2 years ago

kamiyaa commented 2 years ago

https://github.com/RustAudio/rodio/blob/master/src/decoder/symphonia.rs#L136

Just wanted to create an issue tracking this. Am also curious if there is any active work on this? Thank you!

Alch-Emi commented 2 years ago

Bit of a novice here, but it looks like the sampling rate and total number of frames are both available in CodecParameters for the track, but I have no idea how many samples / packet there are, or how to find that information. If anyone else knows how to get that, though, an implementation should be pretty trivial (samples_per_frame * n_frames / sample_rate = length in seconds)

est31 commented 2 years ago

Not all formats have streams where each frame has the same number of samples. E.g. in vorbis the number can vary from frame to frame.

dvdsk commented 11 months ago

I needed this as part of #513. I implemented it following the suggested approach in the symphonia documentation