ffmpeg是一个开源的编解码框架,拥有很强大的功能。 这里主要介绍了"使用ffmpeg将speex、amr音频格式转为mp3和ogg",主要涉及到使用FFMPEG将speex、amr音频格式转为mp3和ogg格式方面的内容,对于使用FFMPEG将speex、amr音频格式转为mp3和ogg格式感兴趣的同学可以参考一下。
场景需要:服务端需要将从客户端APP上传上来的speex、amr格式的语音格式转为mp3和ogg两种格式,这样就可以支持PC所有浏览器(通过html5标签)播放。
[bash]软件下载:
yum install -y automake autoconf libtool gcc gcc-c++
cd /data/soft/
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
wget http://jaist.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
wget http://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz
wget http://www.penguin.cz/~utx/ftp/amr/amrnb-11.0.0.0.tar.bz2
wget http://www.penguin.cz/~utx/ftp/amr/amrwb-11.0.0.0.tar.bz2
wget http://downloads.xiph.org/releases/speex/speex-1.2rc1.tar.gz
wget http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz
tar zxvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure && make && make install
cd ..
tar zxvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure && make && make install
cd ..
tar zxvf opencore-amr-0.1.3.tar.gz
cd opencore-amr-0.1.3
./configure && make && make install
cd ..
tar jxvf amrnb-11.0.0.0.tar.bz2
cd amrnb-11.0.0.0
./configure && make && make install
cd ..
tar jxvf amrwb-11.0.0.0.tar.bz2
cd amrwb-11.0.0.0
./configure && make && make install
cd ..
tar zxvf speex-1.2rc1.tar.gz
cd speex-1.2rc1
./configure && make && make install
cd ..
tar zxvf libogg-1.3.2.tar.gz
cd libogg-1.3.2
./configure && make && make install
cd ..
ldconfig
tar zxvf libvorbis-1.3.5.tar.gz
cd libvorbis-1.3.5
./configure && make && make install
cd ..
wget http://ffmpeg.org/releases/ffmpeg-3.3.tar.gz
tar zxvf ffmpeg-3.3.tar.gz
cd ffmpeg-3.3
./configure --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-libspeex --enable-libvorbis --enable-shared
make
make install
ldconfig
ffmpeg
/usr/local/bin/ffmpeg -i test.amr test.amr.mp3[/bash]
ffmpeg 本身有支持了一些音视频格式的编解码器,但是由于版权问题并不是所有的都支持。例如对于mp3,ffmpeg只有解码包,没有编码包。这就意味着只能将mp3转为其他格式,而不能将其他格式的音视频转为mp3,所以我们才需要手动来安装额外的libmp3lame这个包。
查看ffmpeg本身支持编解码格式可以通过./configure --help来查看。
如果需要转为其他格式的,如果ffmpeg默认没安装对应的编解码包,可自行下载安装,再重新编译安装ffmpeg即可。
补充:安装中间可能遇到一些问题,
1、speex not found using pig-config
解决办法:
vi /etc/profile
添加
export PKG_CONFIG=/usr/bin/pkg-config
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
保存后执行
source /etc/profile
2、
*** If you have an old version installed, it is best to remove it, although
*** you may also be able to get things to work by modifying LD_LIBRARY_PATH、
configure: error: must have Ogg installed!
解决方法:
vi /etc/ld.so.conf
添加 /usr/local/lib
保存后执行 ldconfig
您可以选择一种方式赞助本站
支付宝转账赞助
