找传奇、传世资源到传世资源站!

java将音频转Mp3

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

package cn.com.njws.base;import it.sauronsoftware.jave.AudioAttributes;import it.sauronsoftware.jave.Encoder;import it.sauronsoftware.jave.EncoderException;import it.sauronsoftware.jave.EncodingAttributes;import it.sauronsoftware.jave.InputFormatException;import java.io.File;import cn.com.cola.controller.annotation.Action;@Action("/test")public class testAction { public static void main(String[] args) throws Exception { String path1 = "E:\\f539f6a2-7dba-4bbb-901e-94a28317143f__audio.amr"; String path2 = "E:\\f539f6a2-7dba-4bbb-901e-94a28317143f__audio.mp3"; changeToMp3(path1, path2); } public static void changeToMp3(String sourcePath, String targetPath) { File source = new File(sourcePath); File target = new File(targetPath); AudioAttributes audio = new AudioAttributes(); Encoder encoder = new Encoder(); audio.setCodec("libmp3lame"); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("mp3"); attrs.setAudioAttributes(audio); try { encoder.encode(source, target, attrs); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InputFormatException e) { e.printStackTrace(); } catch (EncoderException e) { e.printStackTrace(); } } }

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复