首页

java 手机语音amr文件转mp3格式 源码下载

java

2020-8-21

1、yum install yasm
2、tar -zxvf lame-3.99.5.tar.gz; ./configure; make; make install
3、 tar -zxvf opencore-amr-0.1.2.tar.gz; ./configure; make; make install
4、 tar -jxvf ffmpeg-3.1.1.tar.xz
5、 ./configure –enable-libmp3lame –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-version3 –enable-shared
6、 make
7、make install
8、vi /etc/ld.so.conf
9、在文件末尾加上:/usr/local/lib
10、 ldconfig
11、ffmpeg 输出版本信息表示安装成功

验证:ffmpeg -i 1.amr 1.mp3
把当前目录下的1.amr转换成1.mp3

package com.rrkd.amrformat.servlet;


import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.rrkd.amrformat.utils.AmrTomp3Util;
import com.rrkd.amrformat.utils.DownloadUtil;


/**
 * Servlet implementation class AmrToMp3Servlet
 */
public class AmrToMp3Servlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AmrToMp3Servlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//1.根据 amr文件路径 下载文件
		String url = request.getParameter("amrurl");
		if( url == null || "".equals(url) ){
			return ;
		}
		
		String path = AmrToMp3Servlet.class.getResource("/").getPath();
		path = path.substring(1,path.indexOf("WEB-INF"));
		path = path   "file/";
		String system = System.getProperties().getProperty("os.name");
		if( system != null && !"".equals(system) && system.toLowerCase().contains("linux")){
			path = "/"   path;
		}
		
		File oldFile = new File(path DownloadUtil.getFileNameFromUrl(url)) ;
		if(!oldFile.exists()){
			oldFile = DownloadUtil.downloadFromUrl(url, path);
		}
		String name = DownloadUtil.getFilenameName(DownloadUtil.getFileNameFromUrl(url));
		final String targetPath = path  name   ".mp3";
		final File target = new File(targetPath);
		if( target.exists()){
			try {
				FileInputStream fis=new FileInputStream(target);
				ServletOutputStream sops=response.getOutputStream();
				DownloadUtil.copyStream(fis,sops,true);
				fis.close();
				sops.close();
				fis=null;
				sops=null;
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}else{
			try {
				AmrTomp3Util.amrToMp3(oldFile.getAbsolutePath(), targetPath);
			} catch (Exception ex) {
				System.out.println("转mp3出现异常:" ex.getMessage());
			}finally{
				try {
					Thread.sleep(200l); //休息200毫秒
					FileInputStream fis=new FileInputStream(target);
					ServletOutputStream sops=response.getOutputStream();
					DownloadUtil.copyStream(fis,sops,true);
					fis.close();
					sops.close();
					fis=null;
					sops=null;
				} catch (FileNotFoundException e) {
					e.printStackTrace();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}
	
}
资源下载此资源下载价格为3D币(VIP免费),请先
资源文件列表
语音转换/09BA16A9-689C-D908-1DB5-4C474297CB42.amr , 6054
语音转换/amrformat/.classpath , 841
语音转换/amrformat/.project , 1042
语音转换/amrformat/.settings/.jsdtscope , 503
语音转换/amrformat/.settings/org.eclipse.core.resources.prefs , 326
语音转换/amrformat/.settings/org.eclipse.jdt.core.prefs , 629
语音转换/amrformat/.settings/org.eclipse.wst.common.component , 479
语音转换/amrformat/.settings/org.eclipse.wst.common.project.facet.core.xml , 345
语音转换/amrformat/.settings/org.eclipse.wst.jsdt.ui.superType.container , 49
语音转换/amrformat/.settings/org.eclipse.wst.jsdt.ui.superType.name , 6
语音转换/amrformat/build/classes/com/amrformat/servlet/AmrToMp3Servlet.class , 3504
语音转换/amrformat/build/classes/com/amrformat/servlet/ServerLoadInitServlet.class , 1204
语音转换/amrformat/build/classes/com/amrformat/utils/Amr2Mp3Util.class , 1393
语音转换/amrformat/build/classes/com/amrformat/utils/DownloadUtil.class , 4139
语音转换/amrformat/build/classes/com/amrformat/utils/QuartzTask$StartThread$1.class , 1189
语音转换/amrformat/build/classes/com/amrformat/utils/QuartzTask$StartThread.class , 924
语音转换/amrformat/build/classes/com/amrformat/utils/QuartzTask.class , 927
语音转换/amrformat/src/com/amrformat/servlet/AmrToMp3Servlet.java , 2939
语音转换/amrformat/src/com/amrformat/servlet/ServerLoadInitServlet.java , 692
语音转换/amrformat/src/com/amrformat/utils/Amr2Mp3Util.java , 783
语音转换/amrformat/src/com/amrformat/utils/DownloadUtil.java , 4001
语音转换/amrformat/src/com/amrformat/utils/QuartzTask.java , 723
语音转换/amrformat/WebContent/META-INF/MANIFEST.MF , 39
语音转换/amrformat/WebContent/WEB-INF/lib/commons-io-2.4.jar , 185140
语音转换/amrformat/WebContent/WEB-INF/lib/jave-1.0.2.jar , 5868832
语音转换/amrformat/WebContent/WEB-INF/web.xml , 1384
语音转换/amrformat-service/.classpath , 1433
语音转换/amrformat-service/.project , 1226
语音转换/amrformat-service/.settings/.jsdtscope , 575
语音转换/amrformat-service/.settings/org.eclipse.core.resources.prefs , 416
语音转换/amrformat-service/.settings/org.eclipse.jdt.core.prefs , 430
语音转换/amrformat-service/.settings/org.eclipse.m2e.core.prefs , 90
语音转换/amrformat-service/.settings/org.eclipse.wst.common.component , 679
语音转换/amrformat-service/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml , 171
语音转换/amrformat-service/.settings/org.eclipse.wst.common.project.facet.core.xml , 300
语音转换/amrformat-service/.settings/org.eclipse.wst.jsdt.ui.superType.container , 49
语音转换/amrformat-service/.settings/org.eclipse.wst.jsdt.ui.superType.name , 6
语音转换/amrformat-service/.settings/org.eclipse.wst.validation.prefs , 50
语音转换/amrformat-service/pom.xml , 1788
语音转换/amrformat-service/src/main/java/com/rrkd/amrformat/servlet/AmrToMp3Servlet.java , 3145
语音转换/amrformat-service/src/main/java/com/rrkd/amrformat/servlet/ServerLoadInitServlet.java , 702
语音转换/amrformat-service/src/main/java/com/rrkd/amrformat/utils/AmrTomp3Util.java , 883
语音转换/amrformat-service/src/main/java/com/rrkd/amrformat/utils/DownloadUtil.java , 4006
语音转换/amrformat-service/src/main/java/com/rrkd/amrformat/utils/QuartzTask.java , 728
语音转换/amrformat-service/src/main/webapp/file/temp.txt , 18
语音转换/amrformat-service/src/main/webapp/WEB-INF/web.xml , 1501
语音转换/ffmpeg-3.1.1.tar.xz , 7806604
语音转换/lame-3.99.5.tar.gz , 1445348
语音转换/opencore-amr-0.1.2.tar.gz , 868977
语音转换/执行.txt , 519
没有账号? 忘记密码?

社交账号快速登录