.net core 在CentOS环境下将微信公众号语音文件amr转化成mp3

微信语音是amr格式,如需mp3格式需要自行转换,

转换方式可以用sox或用ffmpeg,这里我们使用ffmpeg

首先安装系统编译环境

yum install -y automake autoconf libtool gcc gcc-c++

编译所需源码包

yasm:汇编器

wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

tar -xzvf yasm-1.3.0.tar.gz

cd yasm-1.3.0

./configure

make

make install

lame

wget http://jaist.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz

tar -xzvf lame-3.99.5.tar.gz

cd lame-3.99.5

./configure

make

make install

amr支持

wget http://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz

tar -xzvf opencore-amr-0.1.3.tar.gz

cd opencore-amr-0.1.3

./configure

make

make install

amrnb支持

wget http://www.penguin.cz/~utx/ftp/amr/amrnb-11.0.0.0.tar.bz2

tar -xjvf amrnb-11.0.0.0.tar.bz2

cd amrnb-11.0.0.0

./configure

make

make install

amrwb支持

wget http://www.penguin.cz/~utx/ftp/amr/amrwb-11.0.0.0.tar.bz2

tar -xjvf amrwb-11.0.0.0.tar.bz2

cd amrwb-11.0.0.0

./configure

make

make install

ffmpeg

wget http://ffmpeg.org/releases/ffmpeg-2.5.3.tar.bz2

tar -xjvf ffmpeg-2.5.3.tar.bz2

cd ffmpeg-2.5.3

./configure --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-shared

make

make install

编译安装完成后在/etc/ld.so.conf文件末尾加上:/usr/local/lib 然后执行

ldconfig
ffmpeg -i 1.amr 1.mp3                 #AMR转换MP3
var file ="xxx/xxx/xxx.amr";
var newFile = file.Replace(Path.GetExtension(file), ".mp3");
var processStartInfo= new ProcessStartInfo("ffmpeg", $" -i {file} {newFilePath}");
using (var process= Process.Start(processStartInfo))
{
    process?.Close();
}

猜你喜欢

转载自www.cnblogs.com/zhangliang2008/p/13177021.html