Is there any pure java way to convert .wav to .mp3?

前端 未结 6 2027
小鲜肉
小鲜肉 2021-01-01 03:14

I\'ve struggled a lot with Java but could not combine a working example of Java .wav to .mp3 converter. This converter will be used in a Java applet so it should depend only

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-01 03:36

    I use Jump3r to convert wav to mp3 on my project because the html5 player of IE11 can't play wav files.

    Jump3r is the simpliest solution found to run inside a tomcat servlet. I wasn't able to integrate others solutions like jave certainly due to the security manager... Jump3r is a pure java program.

    Jump3r is available on the maven repository (https://mvnrepository.com/artifact/de.sciss/jump3r/1.0.4) and the sources are available on github (https://github.com/Sciss/jump3r)

    To convert a file, you should call the main method (in the following code, I use an inlined version of the main method to catch/throw an IOException if necessary)

    private void convertWavFileToMp3File(File source, File target) throws IOException {
        String[] mp3Args = { "--preset","standard",
            "-q","0",
            "-m","s",
            source.getAbsolutePath(),
            target.getAbsolutePath()
        };
        (new Main()).run(mp3Args);
    }
    

提交回复
热议问题