ffmpeg安装(linux-centos)

  1. 官网下载ffmpeg源码包ffmpeg-xxx.tar.bz2,下载地址
  2. 解压bz2安装包
tar -xjvf ffmpeg-3.3.1.tar.bz2

如果缺少bzip2包需要先安装

yum install -y bzip2
  1. 编译
cd ffmpeg-xxx/
./configure --enable-shared --prefix=/app/ffmpeg

编译可能错误1

  xxx-linux-gcc  is unable to create an executable file.

  C compiler test failed.

缺少gcc库,解决办法添加gcc

yum install gcc

编译可能错误2

yasm/nasm not found or too old . Use --disable-yasm for a crippled build

yasm/nasm 包不存在或者很旧
解决办法安装yasm
下载地址下载1.3.0源码包,依次执行如下命令

tar -xvzf yasm-1.3.0.tar.gz
cd yasm-1.3.0/
./configure
make
make install
  1. 再次编译,依次执行如下命令
cd ffmpeg-xxx/
./configure --enable-shared --prefix=/app/ffmpeg
make
make install

编译完成后会在/app/ffmpeg目录下生成bin,include,lib,share四个目录,进入bin目录执行./ffmpeg -version查看当前版本的详细信息,一般情况会出现如下错误

./ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory

原因是lib目录未加载到链接到系统库中,系统ld目录列表在/etc/ld.so.conf中,打开文件会发现,里面引用了/etc/ld.so.conf.d/下面所有的.conf文件,比如mariadb-x86_64.conf我们只需要创建一个文件并写入lib路径即可,执行命令: vim /etc/ld.so.conf.d/ffmpeg.conf 然后添加一行内容: /app/ffmpeg/lib 之后保存并退出,然后执行 ldconfig 使配置生效,现在再次执行 ./ffmpeg -version 显示就正常了

ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
configuration: --enable-shared --prefix=../../app/ffmpeg/
libavutil      56. 14.100 / 56. 14.100
libavcodec     58. 18.100 / 58. 18.100
libavformat    58. 12.100 / 58. 12.100
libavdevice    58.  3.100 / 58.  3.100
libavfilter     7. 16.100 /  7. 16.100
libswscale      5.  1.100 /  5.  1.100
libswresample   3.  1.100 /  3.  1.100
  1. 测试
./ffmpeg -i test.avi test2.mp4

猜你喜欢

转载自blog.csdn.net/soul_code/article/details/80061820
今日推荐