'Java - getting error with audio input stream for opening mp3 file
I am trying to convert mp3 to wav file and I need the below lines of code to be able to proceed with the conversion post opening the mp3 file, however I get error -
AudioFileFormat inputFileFormat = AudioSystem.getAudioFileFormat(new File("C:/dg.mp3"));
AudioInputStream ais = AudioSystem.getAudioInputStream(new File("C:/dg.mp3"));
Error:
javax.sound.sampled.UnsupportedAudioFileException: file is not a supported file type at javax.sound.sampled.AudioSystem.getAudioFileFormat(Unknown Source) at MP3toWav.main(MP3toWav.java:10)
Any help on this is appreciated? I have searched a lot but unable to get any answers for my problem!
Solution 1:[1]
With default Java API, you can open a .wav file. But cannot open an Mp3 file. Use JMF for open a mp3 file.
Solution 2:[2]
You cannot open mp3 file with the default Java Audio API. You will have to use external API like Mp3agic
Solution 3:[3]
With default Java API you can only open .aiff, .au or .wav files. You could try to convert your .mp3 to a .wav file and then use your new .wav file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kumar |
| Solution 2 | ortis |
| Solution 3 | Krishna |
