Java library for extracting audio information from MP3 files

馋奶兔 提交于 2019-12-07 21:46:45

问题


Is there any freely available library (other than java media framework) that I can use to extract the bit rate (eg. 128 kbps, VBR) and the audio quality (eg 44.1KHz, Stereo) from a MP3 file?

I would like a standalone library that I can incorporate into my application jar, to be deployed on older Macs too that have only Java 1.5 available and I can't get them upgraded or add any big Java library to.

Just to clarify: I will not play, transcode or do anything of the sort with the audio stream itself, I am interested in the metadata only.


回答1:


I confess I do not know much about MP3 files, but you can see from the format specification that all the informations needed are in the 32 bits long header of the file.

You could open the MP3 with a FileInputStream, read the first 4 bytes of the file and, using some simple binary masks, retrieve the informations you need. IMHO using a specialized library for that is a bit of an overkill.




回答2:


Take a look at JAudioTagger, plain simple and easy to use, the data you are looking for is into MP3AudioHeader class, with methods like getBitRate()




回答3:


You can use the LAMEOnJ library:

  • http://openinnowhere.sourceforge.net/lameonj/

This java library is light but you must have the LAMELib installed on target computer.




回答4:


I'm not a java programmer, but i'm pretty sure you could read the mp3 file into a byte array then see http://www.mp3-tech.org/programmer/frame_header.html for frame info.




回答5:


This format specification shows you what's contained the MPEG (mp3) header. You can write code to retrieve this header.



来源:https://stackoverflow.com/questions/5327019/java-library-for-extracting-audio-information-from-mp3-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!