Linux下安装FFmpeg

雪域幽狐 2018-04-27 15:06 阅读:7981


目前网上使用的yum安装FFmpeg版本较低,不能满足需求,需要下载源码安装。
如果需要在Linux下进行H.264编码,需要先安装X264,否则运行时会报Cannot load libcuda.so.1。如果不进行H.264编码,可跳过这步。
git clone http://git.videolan.org/git/x264.git
cd x264
./configure --enable-shared --disable-asm
make
make install

接下来即可安装FFmpeg了
wget http://www.ffmpeg.org/releases/ffmpeg-3.4.2.tar.gz
tar -zxvf ffmpeg-3.4.2.tar.gz
cd ffmpeg-3.4.2
./configure --enable-libx264 --enable-gpl --prefix=/usr/local/ffmpeg
make
make install

安装完后,可在PATH中加入环境变量
/etc/profile
在最后PATH添加环境变量:
PATH=$PATH:/usr/local/ffmpeg/bin

常见问题:
1、如果安装过程中出现以下错误:
yasm/nasm not found or too old. Use –disable-yasm 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 “config.log” produced by configure as this will help
solve the problem.

wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar -zxvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make
make install

2、安装正常,使用时报错
error while loading shared libraries: libx264.so.155: cannot open shared object file: No such file or directory
这是系统不知道so在哪个目录下
解决:
编辑
/etc/ld.so.conf
添加/usr/local/lib,如下

include ld.so.conf.d/*.conf
/usr/local/lib

然后执行ldconfig

0条评论

登陆后可评论