I’m trying to make a tool to convert wav’s to mp3’s then send out a notification when it’s done. (The wav’s will always be 44100Hz 16-bit Stereo files)
My first attempt was to link to JMF then attempt to do this:
public void wavToMP3(String waveFileName, String mp3FileName) throws Exception
{
File file = new File(waveFileName);
AudioInputStream in = AudioSystem.getAudioInputStream(file);
AudioInputStream out;
AudioFormat.Encoding encodedFormat = new AudioFormat.Encoding(javax.media.format.AudioFormat.MPEGLAYER3);
out = AudioSystem.getAudioInputStream(encodedFormat, in);
File outfile = new File(mp3FileName);
AudioSystem.write(out, new AudioFileFormat.Type("MP3","mp3"), outfile);
}
but that results in this error:
Exception in thread “main” java.lang.IllegalArgumentException: Unsupported conversion: mpeglayer3 from PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian
I can’t seem to find what I need to change to fix this, any suggestions?