I'm writing an extension for google chrome. And I have a situation: I've got a link for mp3 file, and I could play it. I could extract duration of it..
But how could I calculate bitrate? Is it possible through some properties? Or through some calculations using file size? If second - how to get filesize?
Do a HEAD request and get the filesize from the Content-Length header. Since you know the duration, you can then calculate the bitrate.
Here I want to share some of my research.
You probably already know this -- the bitrate is stored inside according to the MP3 format specification. But I'm sure you would rather not read the file and deal with all that yourself! Hopefully you can find tools or API's to help. With that in mind...
I looked around for public web APIs that will extract info for MP3's but didn't find anything that jumped out at me.
If you can find a version of ExifTool that you can access from Chrome, it has an API to calculate bitrate.
I looked at the Web Audio API but did not see any mention of reading MP3 files in particular, and therefore no way to extract bitrate.
©2020 All rights reserved.