Ubuntu安装编译FFmpeg

装了三天都快哭了,做个记录。

前两天用Windows+Cygwin装的,最后失败了,卡在执行ffmpeg时候,报错: error while loading shared libraries: cygswscale-5.dll。

于是切换了虚拟机,版本是Ubuntu 14.04 LTS。

参考文章:http://www.imooc.com/article/247113
https://www.imooc.com/article/253497
https://blog.csdn.net/xl4025/article/details/46123773
https://blog.csdn.net/hankerbit/article/details/83834349

步骤一:
如果没有安装git,先sudo apt-get install git,然后直接下载ffmpeg:git clone https://git.ffmpeg.org/ffmpeg.git

步骤二:
安装 gcc,cmake,automake,gdb,nasm,yasm
挨着执行sudo apt-get install xxx命令

步骤三:
编译fdk-aac,x264,speex,SDL2,这几个好像不能用apt-get,要么找不到,要么之后ffmpeg执行configure的时候会报错找不到库文件。

编译 fdk-aac
wget -c https://jaist.dl.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-0.1.6.tar.gz
tar xvf fdk-aac-0.1.6.tar.gz
cd fdk-aac-0.1.6
./configure
make && sudo make install
cd …

编译x264
wget -c http://mirror.yandex.ru/mirrors/ftp.videolan.org/x264/snapshots/last_x264.tar.bz2
bunzip2 last_x264.tar.bz2
tar -vxf last_x264.tar
cd last_x264
./configure --enable-static --enable-shared --disable-asm --disable-avs
make && sudo make install
cd …

编译speex
wget -c http://downloads.us.xiph.org/releases/speex/speex-1.2.0.tar.gz
tar xvf speex-1.2.0.tar.gz
cd speex-1.2.0
./configure
make && sudo make install
cd …

编译SDL2(这个没有会缺少ffplay)
wget -c https://www.libsdl.org/release/SDL2-2.0.10.tar.gz
tar xvf SDL2-2.0.10.tar.gz
cd SDL2-2.0.10
./configure
make && sudo make install
cd …

步骤四:
编译ffmpeg
在ffmpeg文件夹下执行
./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libx264 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-shared --enable-pthreads
make && sudo make install

步骤五:
执行ffmpeg,如果提示未找到命令,参照这篇https://blog.csdn.net/xl4025/article/details/46123773。
sudo cp -i /usr/local/ffmpeg/bin/ffmpeg /usr/bin

如果提示error while loading shared libraries:xxxxx.so cannot open shared object file: No such file or directory.参照https://blog.csdn.net/hankerbit/article/details/83834349。
1.找到xxxxx.so所在的目录,原文写的“/usr/local/lib”,但我提示的文件在“/usr/local/ffmpeg/lib”下。
2.sudo vi /etc/ld.so.conf,在"include ld.so.conf.d/*.conf"下方增加"/usr/local/ffmpeg/lib"。保存后执行sudo ldconfig
在这里插入图片描述
3.sudo /sbin/ldconfig -v
4.export LD_LIBRARY_PATH=/usr/local/ffmpeg/lib

然后ffmpeg就终于可以顺利执行了!
在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值