When calling get_duration on a .webm audio file (audio/webm;codecs=opus) the function always returns zero even though the file has a non-zero length.
import librosa as lr
lr.get_duration(filename=r".\test.webm")
Returns: 0
import librosa as lr
y, sr = lr.load(r".\test.webm")
lr.get_duration(y=y, sr=sr)
Returns: 11.7
Thanks for reporting this. The filename= support in 0.6.3 works via the audioread package, so whatever is going wrong is upstream of us. I suspect it's backend dependent, so what you're reporting might vary depending on whether gstreamer or ffmpeg is used as the backend.
That said, 0.7 (current dev branch) switches most of the audio decoding over to use soundfile, which might handle this correctly off the bat. If it does, then I'd consider this already fixed; if not, I think it's still upstream from us and should be elevated to the libsndfile devs. In either case, I'm not sure there's much we can do here. If you can share a file that causes the issue, it might help us confirm and/or diagnose the problem though.
Thank you for your response.
You were right, even ffmpeg itself shows a 0 duration. Initially I thought the file was fine, since playback was just fine and librosa read it correctly, but now I suspect that there might be an encoding issue - either way, it's not a librosa bug.
Glad you got it sorted out!
Most helpful comment
Thank you for your response.
You were right, even ffmpeg itself shows a 0 duration. Initially I thought the file was fine, since playback was just fine and librosa read it correctly, but now I suspect that there might be an encoding issue - either way, it's not a librosa bug.