Convert MP3 to PCM in Java - java

I want to convert MP3 file to PCM in Java.
How to do that?

Get the mp3plugin.jar of the JMF.
Add it to the run-time class-path of the app. to provide a decoder SPI for MP3.
Get an AudioInputStream for the MP3 from the AudioSystem of Java Sound.
Convert it to PCM using getAudioInputStream(AudioFormat,AudioInputStream).

Related

Exception in reading an MP3 file through AudioSystem.getAudioInputStream(file)

I am trying to read an MP3 file through class javax.sound.sampled.AudioSystem but I am getting an UnsupportedAudioFileException.
My code trying to read the audio file looks like:-
AudioInputStream audioInputStream =
AudioSystem.getAudioInputStream(file);
I am getting the following exception:-
javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file
Does AudioSystem class not support mp3 format? If not then what formats does it supports? Or Am I doing some mistake here?
No it doesn't support MP3 (hence the UnsupportedAudioFileException). The supported files are quite basic (WAV and that sort of thing), so for any advanced codecs you'll need separate libraries.

Java AudioSystem can't read AIFF from a CD

A part of my program has to read AIFF files using Java AudioSystem. The standard AudioSystem implementation does not support AIFF-C (compressed AIFF for audio CDs). I am looking either for an extension to AudioSystem which supports AIFF-C or easy way to convert AIFF-C to AIFF

parse ogg file in java without decoding

I have a .spx file (an Ogg file with Speex-encoded audio). I would like to use Java to pull the Speex-encoded bytes out of the Ogg container.
The problem is, it seems all of the Java libraries I can find (JSpeex, JOrbis) are written with the assumption that I would also like to decode the audio into raw pcm, which I do not.
Is there a generic Ogg format reader library out there for Java? On the other hand, is it possible to use parts of JSpeex or JOrbis to do what I want?
I could not find an Ogg library in Java after some shallow searching.
But if you are willing to implement Ogg parsing from scratch, the words straight from the horse's mouth are readily available:
Ogg bitstream overview
Ogg logical bitstream and framing spec
(Top page: https://www.xiph.org/vorbis/doc/)
I have not worked with Ogg file with Speex-encoded audio but once I have worked on a use case where I wanted to extract opus packets from ogg opus file, without being decoded to pcm audio. You can find that solution in this answer
https://stackoverflow.com/a/65320789/10110652
This piece of code also works for ogg file with vorbis encoding, so may be this might help with speex encoding as well. Do let me know if this works for you.
Happy Coding!!!❤

How to read bit file mpeg video using java

as title.. how to read bit of file mpeg video using java..
I use it for encryption file video.
Regards
Check the PS container format if you are interested how the different (audio and video) streams are multiplexed to a single file.

Can we play speex file from java?

Is it possible to play a speex file from java. I have encoded a wav file to speex file and i can even decode it back to wave file again and play the audio. But i dont want to decode and play the file throught java. Are there any alternatives to play the file?
JSpeex
JSpeex is a Java port of the Speex speech codec (Open Source/Free Software patent-free audio compression format designed for speech). It provides both the decoder and the encoder in pure Java, as well as a JavaSound SPI.
The current version of the JSpeex library is 0.9.2 and it is based on the code from Speex 1.0.3.
As well as the JSpeex library, there is also JavaSound player that uses the library to play any Speex encoded audio file. The player is a modified version of the jlGui player by JavaZOOM.

Categories