Documentation of filesite.io.
https://filesite.io
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.1 KiB
106 lines
2.1 KiB
2 years ago
|
|
||
|
# CentOS 8.5如何编译安装ffmpeg和openh264、fdk-aac?
|
||
|
|
||
|
ffmpeg是一个非常棒的视频处理软件,它能在linux、macos和windows下运行。
|
||
|
|
||
|
下面简单记录下在CentOS 8.5系统里如何从源码编译安装ffmpeg以及它所需要的openh264和fdk-aac软件。
|
||
|
|
||
|
|
||
|
## 1. 安装依赖库和fdk-aac
|
||
|
```
|
||
|
dnf install gcc gcc-c++ git nasm
|
||
|
dnf install fdk-aac fdk-aac-devel freetype freetype-devel
|
||
|
```
|
||
|
|
||
|
CentOS 7 里安装fdk-aac参考:
|
||
|
```
|
||
|
wget "http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm"
|
||
|
rpm -Uvh nux-dextop-release-0-5.el7.nux.noarch.rpm
|
||
|
yum -y install fdk-aac fdk-aac-devel freetype freetype-devel
|
||
|
```
|
||
|
|
||
|
|
||
|
## 2. 下载openh264源码
|
||
|
```
|
||
|
git clone "https://github.com/cisco/openh264.git"
|
||
|
```
|
||
|
|
||
|
推荐用git下载安装,在openh264安装的过程中会用到git。
|
||
|
|
||
|
|
||
|
## 3. 配置ffmpeg所需的openh264目录环境变量
|
||
|
```
|
||
|
export PKG_CONFIG_PATH=openh264源码保存路径
|
||
|
```
|
||
|
|
||
|
|
||
|
## 4. 编译并安装openh264
|
||
|
|
||
|
cd 进入openh264所在目录
|
||
|
```
|
||
|
make
|
||
|
make install
|
||
|
```
|
||
|
|
||
|
安装好之后,记得创建软连接:
|
||
|
```
|
||
|
ln -s /usr/local/lib/libopenh264.so.2.3.0 /usr/lib/libopenh264.so.7
|
||
|
```
|
||
|
|
||
|
具体版本号请查看你安装的openh264。
|
||
|
|
||
|
|
||
|
## 5. 下载ffmpeg源码
|
||
|
```
|
||
|
wget "https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2"
|
||
|
tar -jxvf ffmpeg-snapshot.tar.bz2
|
||
|
```
|
||
|
|
||
|
如果tar无法解压,先安装bzip2:
|
||
|
```
|
||
|
dnf install bzip2
|
||
|
```
|
||
|
|
||
|
|
||
|
## 6. 配置ffmpeg
|
||
|
|
||
|
解压源码后进入源码目录执行:
|
||
|
```
|
||
|
./configure --enable-libopenh264 --enable-libfdk-aac --enable-libfreetype --disable-x86asm
|
||
|
```
|
||
|
|
||
|
|
||
|
## 7. 编译并安装ffmpeg
|
||
|
|
||
|
在ffmpeg目录下执行:
|
||
|
```
|
||
|
make
|
||
|
make install
|
||
|
```
|
||
|
|
||
|
|
||
|
## 8. 测试ffmpeg
|
||
|
|
||
|
```
|
||
|
ffmpeg -version
|
||
|
```
|
||
|
|
||
|
|
||
|
|
||
|
## 补充说明
|
||
|
|
||
|
如果你有安装了x264和x264-devel库,
|
||
|
需要先删除它们,否则ffmpeg执行的时候会报错:
|
||
|
> ffmpeg: error while loading shared libraries: libopenh264.so.7: cannot open shared object file: No such file or directory
|
||
|
|
||
|
删除x264和x264-devel库:
|
||
|
```
|
||
|
dnf remove x264 x264-devel
|
||
|
```
|
||
|
|
||
|
如果在CentOS 7.9中编译安装好之后,出现上述错误,需要安装x264和x264-libs库:
|
||
|
```
|
||
|
yum -y install x264 x264-libs
|
||
|
```
|
||
|
|