娃哈哈好喝-真的!
技术够用就行,吃好喝好睡好!

centos7源码安装ffmpeg6.1

首先安装依赖

1、安装nasm
[root@centos ~]# wget https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/nasm-2.16.03.tar.gz
[root@centos ~]# tar -zxvf nasm-2.16.03.tar.gz
[root@centos ~]# cd nasm-nasm-2.16.03
[root@centos nasm-2.16.03]# ./configure
[root@centos nasm-2.16.03]# make && make install
[root@centos nasm-2.16.03]# nasm -v
NASM version 2.16.03 compiled on May 14 2024
[root@centos nasm-2.16.03]#

如果需要安装别的版本可以去官网找:https://www.nasm.us

2、安装x264
[root@centos ~]# git clone https://code.videolan.org/videolan/x264.git
[root@centos ~]# cd x264/
[root@centos x264]# ls
AUTHORS         config.guess  COPYING  example.c  input     tools       x264cli.h  x264res.manifest
autocomplete.c  config.sub    doc      extras     Makefile  version.sh  x264dll.c  x264res.rc
common          configure     encoder  filters    output    x264.c      x264.h
[root@centos x264]# ./configure --prefix=/usr/x264/ --includedir=/usr/local/include --libdir=/usr/local/lib --enable-shared
[root@centos x264]# make && make install

配置环境变量

# 文件最后追加
[root@centos ~]# vim /etc/profile
export PATH="/usr/x264/bin:$PATH"
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
[root@centos ~]# source /etc/profile

验证是否安装成功

[root@centos ~]# pkg-config --libs x264
-L/usr/local/lib -lx264
[root@centos ~]# x264 --version
x264 0.164.3191 4613ac3
built on May 14 2024, gcc: 4.8.5 20150623 (Red Hat 4.8.5-44)
x264 configuration: --chroma-format=all
libx264 configuration: --chroma-format=all
x264 license: GPL version 2 or later
[root@centos ~]# 

出现上面信息表示安装成功

3、安装ffmpeg

去官网找需要的版本:https://ffmpeg.org//releases

[root@centos ~]# wget https://ffmpeg.org//releases/ffmpeg-6.1.tar.gz
[root@centos ~]# tar -zxvf ffmpeg-6.1.tar.gz
[root@centos ~]# cd ffmpeg-6.1/
[root@centos ffmpeg-6.1]# ./configure --prefix=/data/ffmpeg --enable-gpl --enable-libx264 --enable-shared --extra-ldflags=-L/usr/local/lib --extra-cflags=-I/usr/local/include
[root@centos ffmpeg-6.1]# make
[root@centos ffmpeg-6.1]# make install

验证是否安装成功

[root@centos ~]# ffmpeg -version
ffmpeg version 6.1 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-44)
configuration: --enable-gpl --enable-libx264 --enable-shared --extra-ldflags=-L/usr/local/lib --extra-cflags=-I/usr/local/include
libavutil      58. 29.100 / 58. 29.100
libavcodec     60. 31.102 / 60. 31.102
libavformat    60. 16.100 / 60. 16.100
libavdevice    60.  3.100 / 60.  3.100
libavfilter     9. 12.100 /  9. 12.100
libswscale      7.  5.100 /  7.  5.100
libswresample   4. 12.100 /  4. 12.100
libpostproc    57.  3.100 / 57.  3.100

安装完成

4、安装过程可能会遇到的问题

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

查找libavdevice.so.60这个文件所在位置

[root@centos ~]# find / -name  libavdevice.so.60
/usr/local/lib/libavdevice.so.60
# 将查找的文件目录加入进来
[root@centos ~]# vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib
[root@centos ~]# ldconfig
赞(0)
未经允许不得转载:娃哈哈好喝 » centos7源码安装ffmpeg6.1
分享到: 更多 (0)