package com.hfits.modules.app.xczf.util;
import it.sauronsoftware.jave.*;
import java.io.File;
public class Mp3Util {
/**
* @return mp3文件路径
*/
public void changeToMp3(String sourcePath) {
File source = new File(sourcePath);
String targetPath = sourcePath.substring(0,sourcePath.indexOf("."))+".mp3";
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) {
} catch (InputFormatException e) {
} catch (EncoderException e) {
}
}
public void main(String[] args) {
String path1 = "E:\\hf-app\\xczfApp\\img\\20190527_172209.amr";
changeToMp3(path1);
}
}
博客展示了一个Java的Mp3工具类代码,包名为com.hfits.modules.app.xczf.util,引入了it.sauronsoftware.jave相关类,定义了Mp3Util类,体现了Java在音频处理方面的应用。
1万+

被折叠的 条评论
为什么被折叠?



