基本信息
源码名称:java将音频转Mp3
源码大小:5.59M
文件格式:.zip
开发语言:Java
更新时间:2020-10-19
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍



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();  
	        }  
	    } 
}