Red Hat (Centos7) 下安装最新 ffmpeg

FFmpeg既是一款音视频编解码工具,同时也是一组音视频编解码开发套件,作为编解码开发套件,它为开发者提供了丰富的音视频处理的调用接口。
FFmpeg提供了多种媒体格式的封装和解封装,包括多种音视频编码、多种协议的流媒体、多种色彩格式的转换、多种采样率的转换、多种码率转换等;FFmpeg框架提供了多种丰富的插件模块,包含封装与解封装的插件、编码与解码的插件等。
[root@ip-172-31-32-39 ec2-user]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.3 (Ootpa)

1、Red Hat 下安装最新 ffmpeg

wget http://www.ffmpeg.org/releases/ffmpeg-4.3.2.tar.gz
tar -zxvf ffmpeg-4.3.2.tar.gz
cd ffmpeg-4.3.2
[root@ip-172-31-32-39 ffmpeg-4.3.2]# ./configure --prefix=/usr/local/ffmpeg
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.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.

报错缺少gcc,安装一下

yum install gcc*
装完之后再执行编译前检查:
意料之中出现未安装 yasm 汇编编译器的报错
[root@ip-172-31-32-39 ffmpeg-4.3.2]# ./configure --prefix=/usr/local/ffmpeg
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.

2、安装 yasm 汇编编译器
yasm

wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xzf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure --prefix=/usr/local/
make
make install
cd /usr/local/bin/
[root@ip-172-31-32-39 bin]# ./yasm --version
yasm 1.3.0
Compiled on Sep  2 2021.
Copyright (c) 2001-2014 Peter Johnson and other Yasm developers.
Run yasm --license for licensing overview and summary.

3、加环境配置文件后再次编译ffmpeg

# tail -3 /etc/profile
##
export PATH=/usr/local/bin:$PATH
# source /etc/profile

#验证yasm命令

[root@ip-172-31-32-39 ffmpeg-4.3.2]# yasm
yasm: No input files specified

#重新编译

./configure --prefix=/usr/local/ffmpeg
make
make install

#验证ffmpeg

# cd /usr/local/
# ls
bin  etc  ffmpeg  games  include  lib  lib64  libexec  sbin  share  src
# cd ffmpeg/
# ls
bin  include  lib  share
# cd bin/
# ls
ffmpeg  ffprobe
[root@ip-172-31-32-39 bin]# ./ffmpeg -version
ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 8 (GCC)
configuration: --prefix=/usr/local/ffmpeg
libavutil      56. 51.100 / 56. 51.100
libavcodec     58. 91.100 / 58. 91.100
libavformat    58. 45.100 / 58. 45.100
libavdevice    58. 10.100 / 58. 10.100
libavfilter     7. 85.100 /  7. 85.100
libswscale      5.  7.100 /  5.  7.100
libswresample   3.  7.100 /  3.  7.100

4、拓展
上面只是简单的安装,FFmpeg本身支持一些音视频编码格式、文件封装格式与流媒体传输协议,但是支持的数量有限,FFmpeg所做的只是提供一套基础的框架,所有的编码格式、文件封装格式与流媒体协议均可以作为FFmpeg的一个模块挂载在FFmpeg框架中。这些模块以第三方的外部库的方式提供支持,可以通过FFmpeg源码的configure命令查看FFmpeg所支持的音视频编码格式、文件封装格式与流媒体传输协议,对于FFmpeg不支持的格式,可以通过configure --help查看的第三方外部库,然后通过增加对应的编译参数选项进行支持。

例如需要自己配置FFmpeg支持哪些格式,比如仅支持H.264视频与AAC音频编码,可以调整配置项将其简化如下:

./configure --enable-libx264 --enable-libfdk-aac --enable-gpl --enable-nonfree --prefix=/usr/local/ffmpeg

报错:

ERROR: libfdk_aac not foundIf 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.

fdk-acc下载

wget https://sourceforge.net/projects/opencore-amr/files/fdk-aac/fdk-aac-2.0.2.tar.gz
tar xzf  fdk-aac-2.0.2.tar.gz
cd fdk-aac-2.0.2
./configure  --prefix=/usr/local/
make
make install

再次编译检查./configure --enable-libx264 --enable-libfdk-aac --enable-gpl --enable-nonfree --prefix=/usr/local/ffmpeg
报错:

ERROR: libx264 not foundIf 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.

libx264 下载:
x264

# https://code.videolan.org/videolan/x264# 建议下载稳定版
# https://code.videolan.org/videolan/x264/-/tree/stable# 其他版本
# https://ftp.videolan.org/pub/x264/snapshots/
#git clone https://code.videolan.org/videolan/x264.gitwget http://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20191217-2245-stable.tar.bz2
tar xjf x264-snapshot-20191217-2245-stable.tar.bz2
cd x264-snapshot-20191217-2245-stable
./configure --prefix=/usr/local --enable-shared --enable-static --disable-asm
make
make install

vim /etc/profile //文件末尾加入下面内容

export PATH=/usr/local/x264/bin:$PATH
export PATH=/usr/local/x264/include:$PATH
export PATH=/usr/local/x264/lib:$PATH

vim /etc/ld.so.conf //增加以下内容
/usr/local/x264/lib //添加x264库路径,添加完保存退出

# ldconfig //使配置生效

vim /etc/ld.so.conf //增加以下内容
/usr/local/ffmpeg/lib //添加ffmpeg库路径,添加完保存退出
ldconfig //使配置生效

使用方法:在./configure之前输入
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH //(此路径为.pc文件所在路径),可使用
echo $PKG_CONFIG_PATH //查看有没设置生效

再次执行编译检查

./configure --enable-libx264 --enable-libfdk-aac --enable-gpl --enable-nonfree --prefix=/usr/local/ffmpeg
make
make install

验证

[root@ip-172-31-32-39 bin]# ./ffmpeg --version
./ffmpeg: error while loading shared libraries: libfdk-aac.so.2: cannot open shared object file: No such file or directory

报错了,但是这个文件是有的

[root@ip-172-31-32-39 bin]# find / -name libfdk-aac.so*
/usr/local/lib/libfdk-aac.so.2.0.2
/usr/local/lib/libfdk-aac.so.2
/usr/local/lib/libfdk-aac.so
/data/fdk-aac-2.0.2/.libs/libfdk-aac.so.2.0.2
/data/fdk-aac-2.0.2/.libs/libfdk-aac.so.2
/data/fdk-aac-2.0.2/.libs/libfdk-aac.so
在/etc/profile添加一行,整体如下(包含上面添加的)
##
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/lib/:$PATH
export PATH=/usr/local/x264/bin:$PATH
export PATH=/usr/local/x264/include:$PATH
export PATH=/usr/local/x264/lib:$PATH
source /etc/profile

在/etc/ld.so.conf添加一行,整体如下(包含上面添加的)

vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/x264/lib
/usr/local/ffmpeg/lib
/usr/local/lib
# ldconfig   # 加载/etc/ld.so.conf
[root@ip-172-31-32-39 bin]# ./ffmpeg -version
ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 8 (GCC)
configuration: --enable-libx264 --enable-libfdk-aac --enable-gpl --enable-nonfree --prefix=/usr/local/ffmpeg
libavutil      56. 51.100 / 56. 51.100
libavcodec     58. 91.100 / 58. 91.100
libavformat    58. 45.100 / 58. 45.100
libavdevice    58. 10.100 / 58. 10.100
libavfilter     7. 85.100 /  7. 85.100
libswscale      5.  7.100 /  5.  7.100
libswresample   3.  7.100 /  3.  7.100
libpostproc    55.  7.100 / 55.  7.100

可以阅读下如下几篇:
https://www.jianshu.com/p/3641c2ade359
https://blog.csdn.net/sunxiaopengsun/article/details/53925647
https://blog.csdn.net/qq_41678939/article/details/106611111
https://blog.csdn.net/smily77369/article/details/114926723?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_title~default-0.control&spm=1001.2101.3001.4242
https://blog.csdn.net/weixin_42499899/article/details/116727219?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_title~default-1.control&spm=1001.2101.3001.4242
可以按照以下网址联网下载最新版本或者使用安装包里面的软件

yasm
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gzx264
wget ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2fdk-acc
wget http://sourceforge.net/projects/opencore-amr/files/fdk-aac/ame
wget http://ufpr.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gzopus
wget http://downloads.xiph.org/releases/opus/opus-1.1.tar.gzogg
wget http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gzvorbis
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gzlibvpx
wget git clone https://github.com/webmproject/libvpx.gitxvidcore
wget http://downloads.xvid.org/downloads/xvidcore-1.3.4.tar.gzlibtheora
wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz

Red Hat (Centos7) 下安装最新 FFmpeg相关推荐

  1. bugzilla dbd-mysql_在Red Hat Linux下安装配置Bugzilla

    1.App 2.CGI 3.Date::Format(对应的包为:TimeDate-1.16.tar.gz) 4.DBI过程较长(要GCC包),在安装DBI-1.45.tar.gz之前,要先装gcc- ...

  2. 在Red Hat Linux5下构建LAMP网站服务平台之MySQL、PHP的安装与配置

    在Red Hat Linux5下构建LAMP网站服务平台之MySQL.PHP的安装与配置 2010-09-09 16:40:49 标签:PHP Linux mysql RedHat [推送到技术圈] ...

  3. 在CENTOS7下安装kubernetes填坑教程(原创)

    kubernetes(以下简称"k8s")目前是公认的最先进的容器集群管理工具,在1.0版本发布后,k8s的发展速度更加迅猛,并且得到了容器生态圈厂商的全力支持,这包括coreos ...

  4. Centos7下安装Docker

    Centos7下安装Docker(详细的新手装逼教程) 参考: https://www.cnblogs.com/qgc1995/archive/2018/08/29/9553572.html 早就听说 ...

  5. linux 安装redis2.8.3,centos7下安装Redis2.8版本步骤

    Redis 简介 Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可以再次加载进行使用. Redis不仅仅支持简单的key-value类型的数据,同时还提供list,set,zs ...

  6. Centos7下安装Seafile实现私有网盘

    Seafile是一个开源.专业.可靠的云存储平台:解决文件集中存储.共享和跨平台访问等问题,由北京海文互知网络有限公司开发,发布于2012年10月:除了一般网盘所提供的云存储以及共享功能外,Seafi ...

  7. linux Fedora安装桌面,CentOS6.x\Red Hat\Fedora\Linux 安装Wine 1.7.48 桌面运行环境教程

    Open Source Software for running Windows applications on other operating systems Wine ("Wine Is ...

  8. linux Centos7下安装python3及pip3

    linux Centos7下安装python3及pip3 先去python官网下载python3安装包 执行命令: wget https://www.python.org/ftp/python/3.6 ...

  9. 学习笔记(1)centos7 下安装nginx

    学习笔记(1)centos7 下安装nginx 这里我是通过来自nginx.org的nginx软件包进行安装的. 1.首先为centos设置添加nginx的yum存储库 1.通过vi命令创建一个rep ...

最新文章

  1. 壁咚Java 彻底搞定String、StringBuilder、StringBuffer
  2. 【从零开始自制CPU之学习篇03】锁存器与触发器
  3. 阅文集团副总裁傅徐军:最佳技术架构选型方法论
  4. Linux内核和Linux发行版(了解)
  5. 【elasticsearch】es一直重启,报错日志是分片无法分配
  6. hashmap扩容_面试官问:HashMap在并发情况下为什么造成死循环?一脸懵
  7. SpringBoot集成JWT 实现接口权限认证
  8. 截取指定字符前_Excel字符函数(1):利用3个函数提取邮箱中的域名
  9. Win7系统的开机个性化
  10. 用给定的key对字符串进行sha256加密-postman预处理
  11. android常用地图坐标转换
  12. mac 桌面显示服务器,隐藏 Mac 桌面内容的三种方法 | 一日一技 · Mac
  13. MySQL的三层架构(连接认证、解析优化和存储引擎)
  14. 微信公众号三方平台开发【代微信公众号接收消息事件并响应】
  15. 小程序点餐系统——首页
  16. 模态框-model dialog
  17. http://blog.sina.com.cn/s/blog_7f5ad8c20101cnna.html#commonComment
  18. create-react-app配置总结
  19. 流氓不可怕,就怕流氓有文化 Re: 人穷怪物瘠,拉不出屎怪茅坑
  20. 了解python语言的开发者_Python开发者

热门文章

  1. EARTH DATA网站注册走过的坑
  2. Q/W防洪跳转页面/微信小程序跳转到未备案域名
  3. 抖音自媒体火爆短视频如何造?
  4. 解决Windows11 Microsoft Store微软商店无法联网 Windows聚焦不更新 微软账户无法登录等
  5. caffe中loss函数代码分析--caffe学习(16)
  6. Adobe或QQ的oxc000007b错误解决方案.
  7. FreeRTOS入门
  8. ace 官网地址以及相关的下载地址--防止自己忘记
  9. java自动填充_java 如何自动填充网页上的用户名和密码?
  10. 小程序或者公众号授权给第三方平台流程