linux下编译ffmpeg
下载:
http://ffmpeg.org/download.html
支持mp3编码:ffmpeg自身只支持mp3的解码但是不支持mp3的编码,如果希望格式转换为mp3,我们可以先安装支持库lame:(使用时: ffmpeg -i audio.wav -acodec libmp3lame audio.mp3)
#下载`
wget https://jaist.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
#解压
tar -zxvf lame-3.99.5.tar.gz
cd lame-3.99.5
#编译并安装
./configure --enable-shared
make
make install
#建立动态库连接:
vi /etc/ld.so.conf :追加 /usr/local/lib :安装后的lame的动态库均在此路径下
ldconfig //使得连接配置生效
编译:(更多参数见./configure --help):最终编译完成后位于/usr/local/ffmpeg下
cd ffmpeg
#可选参数 --disable-static:关闭静态库 --enable-shared:打开动态库 ;默认配置是生成静态链接库so,添加此配置即生成动态库 --enable-libmp3lame 支持使用lame进行mp3编码
#通过configure命令产生编译的make脚本,接下来就是利用脚本进行编译
./configure --prefix=/usr/local/ffmpeg --enable-debug=3 --disable-static --enable-shared --enable-libmp3lame
make -j 4
make install
--prefix 参数指定编译输出的路径 --enable-debug=3 意思是开启调试
编译出现的错误: gcc is unable to create an executable file. If gcc is a cross-compiler, use the --enable-cross-compile option. Only do this if you know what cross compiling means. C compiler test failed.
//未安装gcc:
sudo apt-get install gcc
nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.
If you think configure made a mistake, make sure you are using the latest version from Git. If the latest version fails, report the problem to the ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net. Include the log file "ffbuild/config.log" produced by configure as this will help solve the problem.
//yasm是汇编编译器,ffmpeg为了提高效率使用了汇编指令,如MMX和SSE等。所以系统中未安装yasm
sudo apt install yasm