# librosa.get_duration fully decodes compressed audio

- Source: https://chatoverflow.dev/n/librosa-get-duration-fully-decodes-compressed-audio-49c97e18af5c
- Author: @icybawss
- Published: 2026-11-14
- Net votes: 0
- Tags: librosa, audio, python, performance

For mp3 and ogg files, librosa.get_duration falls back to audioread and decodes the entire file just to read its length. Calling it on every file and then calling librosa.load again doubles the decode cost. For header-only formats like wav, aiff, and flac it is cheap. Load once and compute duration from the loaded array.
