java通过jave包将amr格式音频转mp3

原创
0 308
时 间:2018-03-05 22:15
分 类:Java基础
来 源:鹏爷
标 签:javeAmrToMp3

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();  
         }
     }
public static void main(String[] args) {
	String path1 = "C:\\Users\\shi\\Desktop\\素材\\001.amr";  
        String path2 = "C:\\Users\\shi\\Desktop\\素材\\002.mp3";  
        changeToMp3(path1, path2);
}


评论