问题
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