html5 audio. How to get bitrate

后端 未结 1 1957
慢半拍i
慢半拍i 2021-01-06 11:44

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 cou

相关标签:
1条回答
  • 2021-01-06 12:02

    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.

    0 讨论(0)
提交回复
热议问题