首先要安装各种解码器
1、lame
lame-3.99.5.tar.gz
Url:http://sourceforge.net/project/showfiles.php?group_id=290&package_id=309
安装方法如下:
1 tar -zxvf lame-3.99.5.tar.gz 2 cd lame-3.99.5 3 ./configure
4 make 5 make install
如果出现如下错误:
no acceptable C compiler found in $PATH
(在线安装gcc)# yum -y install gcc
2、libogg
libogg-1.3.2.tar.gz
Url:http://www.xiph.org/downloads/
安装方法如下:
1 tar -zxvf libogg-1.3.2.tar.gz
2 cd libogg-1.3.2
3 ./configure
4 make
5 make install
3、libvorbis
libvorbis-1.1.2.tar.gz
Url:http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
(libvorbis依赖于libogg, 所以libogg必须先于libvorbis安装)
安装方法如下:
1 tar -zxvf libvorbis-1.1.2.tar.gz
2 cd libvorbis-1.1.2
3 ./configure
4 make 5 make install
出现如下错误
error: C++ preprocessor "/lib/cpp" fails sanity check See `config.log' for more details
# yum install glibc-headers
# yum install gcc-c++
4、xvid
xvidcore-1.3.2.tar.gz
Url:http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
安装方法如下:
1 tar zvxf xvidcore-1.3.2.tar.gz 2 cd xvidcore-1.3.2/build/generic/generic/
3 ./configure
4 make
5 make install
5、x264
latest_x264.tar.bz2 (其中包含的目录是 x264-snapshot-20131023-2245)
Url:http://www.videolan.org/developers/x264.html
ftp://ftp.videolan.org/pub/videolan/x264/snapshots/
安装方法如下:
1 tar -jxvf latest_x264.tar.bz2
2 ./configure
3 make
4 make install
出现如下错误:
Minimum version is yasm-1.2.0 If you really want to compile without asm, configure with --disable-asm. 提示没有asm 汇编工具,我们要先安装一下 asm
tar zxvf yasm-0.7.2.tar.gz
cd yasm-0.7.2
./configure
make
make install
6、libdts
libdca-0.0.5.tar.bz2
Url: http://www.videolan.org/developers/libdca.html
安装方法:
1 tar -jxvf
libdca-0.0.5.tar.bz22 ./configure
3 make
4 make install
7、a52
a52dec-0.7.4.tar.gz (这个库从2002年就没有更新过了)
http://liba52.sourceforge.net/downloads.html
安装方法:
1 tar -vxvf
a52dec-0.7.4.tar.gz2 ./configure
3 make
4 make install
1 tar -vxvf
faad2-2.7.tar.gz2 ./configure
3 make
4 make install
1 tar -vxvf
faac-1.28.tar.gz
2 ./configure
3 make
4 make install
1
t ar -vxvf
amrnb-10.0.0.0.tar.bz2 2 ./configure
3 make
4 make install
11、amr-wb
amrwb-7.0.0.1.tar.gz
http://ftp.penguin.cz/pub/users/utx/amr/ ( 从此处下载最新版本 )
安装方法:
1 tar -vxvf
amrwb-7.0.0.1.tar.gz
2 ./configure
3 make
4 make install
12、最关键的一步, 安装ffmpeg
ffmpeg-0.4.9-p20051120.tar.bz2
1 tar -jxvf ffmpeg-0.4.9-p20051120.tar.bz2
2 ./configure
3 make
4 make install
在./configure的时候会报错, 提示说没有libopencore-amrnb和libopencore-amrwb两个库. 我参考了 [2], 使用如下命令安装它们:
1sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev
查看版本 ffmpeg -version
查看是否支持编码解码 DE D代表Decode(编码) E代表Encode(解码) ffmpeg -formats
查看帮助 ffmpeg -help
ffmpeg所有的安装tag.gz
http://yunpan.cn/cwHG5PBWfF8Xe 访问密码 de12
amr转MP3插件
源码包地址:
http://yunpan.cn/cw3QMRRfRVcpD 访问密码 a296
很好的2片文章
http://my.oschina.net/ethan09/blog/372435?p=1
Linux获取音频时长: ffmpeg -i /usr/test.mp3 2$amp;>amp;$amp;1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//
/**
* ffmpeg获取音频时长
* @return
*/
public static String getAudioTimeLength(File file){
StringBuffer ffmpeg_shell= new StringBuffer();
ffmpeg_shell.append( "ffmpeg" );
ffmpeg_shell.append( " " );
ffmpeg_shell.append( "-i " +file.getPath());
ffmpeg_shell.append( " " );
ffmpeg_shell.append( "2$amp;" );
ffmpeg_shell.append( ">amp;" );
ffmpeg_shell.append( "$amp;" );
ffmpeg_shell.append( "1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//" );
System. out .println( "执行的命令集合 " +ffmpeg_shell.toString());
String os = System. getProperty( "os.name" );
String shell[];
if (os.toLowerCase().startsWith( "win" )){
shell= new String[]{ "cmd" ,ffmpeg_shell.toString()};
} else {
shell= new String[]{ "/bin/sh" , "-c" ,ffmpeg_shell.toString()};
}
return ShellExcuter. exec(shell);
}
/**
* 格式化音频时长 00:00:07.76
*/
public static String formatDurationTime(String duration){
try {
String audioTime=duration.replace( "." , ":" ).substring(duration.indexOf( ":" )+1);
String time_hh=audioTime.substring(audioTime.lastIndexOf( ":" )-5).split( ":" )[0]; //时
String time_mm=audioTime.substring(audioTime.lastIndexOf( ":" )-2).split( ":" )[0]; //分
String time_ss=audioTime.substring(audioTime.lastIndexOf( ":" )+1); //秒
Calendar calendar= Calendar.getInstance();
calendar.set(Calendar. HOUR , Integer. parseInt(time_hh));
calendar.set(Calendar. MINUTE , Integer.parseInt(time_mm));
calendar.set(Calendar. SECOND , Integer. parseInt(time_ss));
SimpleDateFormat format= new SimpleDateFormat( "hh:mm" );
String retunTime=format.format(calendar.getTime());
if (time_hh.contains( "00" )){
retunTime=retunTime.replace( "12" , "00" );
}
Integer sub_ss=Integer.parseInt(duration.substring(duration.lastIndexOf( "." )).replace( "." , "" ));
if (sub_ss>60){
sub_ss=sub_ss%60;
}
return retunTime+ ":" +sub_ss;
} catch (Exception e) {
// TODO : handle exception
System. out .println( "格式化当前音频时长错误" );
}
return "00:00:00" ;
}
版权声明:本文为oQiDai123456原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。