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.
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.
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()
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.
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.
This format specification shows you what's contained the MPEG (mp3) header. You can write code to retrieve this header.
Related
I have created a GUI using java Swing which displays some images. I have been testing it and have managed to create some labels which I have filled with JPEG images as a test.
Now, I face the problem that I cannot display the actual files i need to display because they are .nd2 files (from a Nikon microscope). I have been looking at how to use the Bio-formats and/or IJ packages to do so...but I don't know where to start.
Can anyone help? I am using the Eclipse IDE for Java
About the format
From https://www.file-extensions.org/
... The ND2 format uses JPEG-2000 compression, and also can be
uncompressed or Zip-compressed ...
As mentioned in read jpeg2000 files in java
JPEG 2000 seems to be not included inside standard Java SDK.
Potential solutions
1. Use Open JPEG + existing JNI wrapper
I would try out https://github.com/uclouvain/openjpeg and search for some java wrappers to use openjpeg (e.g. look at https://github.com/barmintor/openjpeg for an JNI approach for maven).
2. Use Open JPEG + Write own JNI wrapper
Another approach would be to look at
https://github.com/ThalesGroup/JP2ForAndroid/blob/master/library/src/main/java/com/gemalto/jp2/JP2Decoder.java , inspect involved classes etc. and write an own JNI wrapper
The mentioned github reposoitory code writes to android bitmap, so not directly usable for your Swing project, but it shows you the way to decode JPEG2000 format by native calls to OpenJPEG library
How to convert a byte[] to a BufferedImage in Java? describes conversion from byte array to a buffered image - so these information should help you to read the image data into a buffered image (so usable in Swing).
I have some .ogg sound files that must be merged together.But the problem is in that the java only support .wav extension (as I used AudioSystem and AudioInputStream).
I've searched among different pages for converting and I've not found a better way than.
Do you know a better way other than using Command line tool?
I think you may have to inspect and tinker with the source code. This can be obtained from various libraries that have JOrbis and other files needed for ogg playback and encoding (there are several on github).
For a project where I needed to load decompressed ogg files (that were originally wav) into memory, I used source code from the example OggPlayer (usually included in the package) and intercepted the bytes before they were written to a SourceDataLine. You can maybe also find a hook in example code that compresses wav to ogg and then link the two parts.
I'm developing a simple audio player in java. The only advanced feature I need is a frequency filter. It's not necessarily a full-featured equalizer function, with different gains for specific frequency ranges: a low pass filter which cuts frequencies higher than a specified value would be enough.
I studied jlGui which has an equalizer, but it only works with MP3 data, while the files I will be playing are OGG.
Browsing through various answers I found that an ffmpeg wrapper like Xuggler or Jave could be a solution. But I didn't find any tutorial, not even a starting point on how to handle frequency filtering with ffmpeg.
Also JMF is described as a valid choice for implementing such a function, but I found nothing specific enough.
http://www.cs.ubc.ca/~kvdoel/jass/doc/index.html
This is the JavaDoc for the JASS project by UBC Vancouver. It's free for non-commercial use. You should be able to implement most kinds of filters with it. Check the URL few levels up for actual source download.
I'm ending up using this solution (for windows applications) : Equalizer APO
It makes use of the Audio Processing Object technology available on Windows Vista and later. My application just needs to edit a configuration text file and the APO does the rest.
Obviously, it is platform dependent, and I must install an external application for my filter to work, but it is acceptable in my case, and it is very easy to implement.
I found an old project called JEQ
It is based on javax.sound and uses IIR to create a 10/15/25/31-band equalizer. It works on PCM data (not just MP3 like others) so I hope I can make it work with OGG. My only concerns are about output quality, which wasn't very good in some of my tests. I'll have to investigate
I work on an audio Importer in JAVA (used in a drum sequencer) and I have the following problem with importing AIFF files:
I have 2 AIFF files of the same type (24bit, 44100kHz, mono), one is created on a Mac, the other is created with wavelab on a windows computer. Both files are uncompressed PCM, both are FORM == AIFF.
The AIFF from the Mac is BigEndian (as it should be),
the AIFF from Wavelab (windows) is LittleEndian.
Both files can be played back properly in Wavelab (Windows) as well as in Quicktime (Windows).
How can these tools detect the endianness of these files? In any way it must be possible, otherwise at least one of the files would sound just like noise (that's what happen in my application).
Is there some hidden information within the file header or any other way to determine the endianness of the AIFF file?
Any suggestions?
Thanks a lot
A quick googling says, AIFF files are big endian.
However according to Wikipedia there is another format called AIFF-C that compresses data. Apple uses little endian these days and created a fake compression method named sowt that essentially means "no compression but little endian". You might have to check for that.
Apart from that, plain AIFF provides no way to check for endianness. A standard AIFF that is encoded in little endian seems to violate the specification.
I want to record audio and save to my server as mp3 files, i googled and find like this
But it is not free and open source
How can i record audio as mp3 in java and php ?
In terms of Java, you could record with standard Java sound and then use something like lameonj to do the mp3 encoding - all free tools!
This question is the same as yours and the person was able to come up with a solution (which he posted as an answer).
A little additional information. It is possible to record sound in an applet. See this page for information on Java Sound and applets. You'll need to sign your applet, which isn't hard to do. The answer to question 5 doesn't mention this but you can create your own (untrusted) certificate with which to do the signing. This question here on SO has some information on self-signing code.
I solved my problem, I used lame library to encode mp3, If you want to pure code to encode mp3, you can use this
Its using java based lame library