javaaudiomp3mediaamr

How to convert Mp3 to Amr Audio Format in Java


I'm writing a Java application and I'd like to convert Mp3 to Amr audio format. So, I could'nt success since there are no documentations or libraries to help. if possible, could you any hint about how to process, with examples.

Thanks.


Solution

  • I have found this library called jave you can convert a media format to another format. you can see the library here

    Here is a sample code that I did using the said plugin

    Encoder encoder = new Encoder();
        EncodingAttributes attributes = new EncodingAttributes();
        attributes.setFormat("wav");
        AudioAttributes audio = new AudioAttributes();
        audio.setBitRate(new Integer(64000));
        audio.setChannels(new Integer(1));
        audio.setSamplingRate(new Integer(22050));
        attributes.setAudioAttributes(audio);
    
        File source = new File("mysong.mp3");
        File target = new File("mysong.wav");
        try {
            encoder.encode(source, target, attributes);
        } catch (IllegalArgumentException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (InputFormatException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (EncoderException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    

    The code I posted basically converts the mp3 to wav