Skip to content Skip to sidebar Skip to footer

Html5 Audio. How To Get Bitrate

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 bi

Solution 1:

Update:

Do a HEAD request and get the filesize from the Content-Length header. Since you know the duration, you can then calculate the bitrate.

Research:

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.

  • There is a Javascript library called SoundManager that looked promising, but it does not accurately 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.

Post a Comment for "Html5 Audio. How To Get Bitrate"