1、系统准备
安装好Centos7.9,并打好系统补丁,安装一些常用工具,关闭防火墙,
yum -y update yum -y install git yum -y install vim yum -y install unzip yum -y install net-tools yum -y install wget yum -y install openssl-devel yum -y install bzip2 gcc gcc-c++ gmp-devel mpfr-devel libmpc-devel make cmake yum -y install zlib yum -y install zlib-devel关闭SELINUX
getenforce ##查看下状态 vim /etc/selinux/config ##修改配置文件,将SELINUX=enforcing改为SELINUX=disabled reboot ##重启后生效关闭防火墙
systemctl status firewalld.service ##查看防火墙运行状态 systemctl disable firewalld.service ##从下次开始关闭防火墙 systemctl stop firewalld.service ##关闭防火墙2、yum安装gcc8
添加上CentOS SCLo RH库,装上gdb8的依赖devtoolset-8-build
sudo yum -y install centos-release-scl-rh sudo yum -y install devtoolset-8-build安装相应的gdb
sudo yum -y install devtoolset-8-gdb同样,也可以安装相应版本的gcc-g++
sudo yum -y install devtoolset-8-gcc devtoolset-8-gcc-c++yum安装完后,原来的gcc不覆盖,所以需要执行enable脚本更新环境变量
sudo source /opt/rh/devtoolset-8/enable ##有时候提示没有文件,需要进入到目录下运行source enable既可 cd /opt/rh/devtoolset-8/ source enable gcc -version ##检查gcc 版本是否切换到 gcc 8了 scl enable devtoolset-8 bash ##或者这个命令启用可以通过加入到profile里面开机自动source,vim /etc/profile, 跳到最后一行加入以下内容
source /opt/rh/devtoolset-8/enable3、安装Cmake 3.21.0
下载源码包并编译安装
cd /home wget https://github.com/Kitware/CMake/releases/download/v3.21.0-rc3/cmake-3.21.0-rc3.tar.gz tar -xvf cmake-3.21.0-rc3.tar.gz mv cmake-3.21.0-rc3 cmake ##重新命名包 cd cmake ./bootstrap make -j4 make install cd /home/cmake/bin cmake ##测试cmake,如下文,则安装正常。 ##Usage ## cmake [options] <path-to-source> ## cmake [options] <path-to-existing-build> ## cmake [options] -S <path-to-source> -B <path-to-build> ##Specify a source directory to (re-)generate a build system for it in the ##current working directory. Specify an existing build directory to ##re-generate its build system. ##Run 'cmake --help' for more information.4.安装ffmpeg
4.1、编译安装
创建编译目录
cd /home mkdir ffmpeg_sources/ cd /home/ffmpeg_sources/安装NASM
curl -O -L https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2 tar -xvf nasm-2.14.02.tar.bz2 yum -y install autoconf automake libtool cd nasm-2.14.02 ./autogen.sh ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" make -j4 make install安装Yasm
cd /home/ffmpeg_sources curl -O -L https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz tar -xvf yasm-1.3.0.tar.gz cd yasm-1.3.0 ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" make -j4 make install安装libx264
cd /home/ffmpeg_sources git clone --depth 1 https://code.videolan.org/videolan/x264.git cd x264 PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static make -j4 make install安装libx265
cd /home/ffmpeg_sources git clone https://github.com/videolan/x265.git cd /home/ffmpeg_sources/x265/build/linux cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source make -j4 make install安装libfdk_aac
cd /home/ffmpeg_sources git clone --depth 1 https://github.com/mstorsjo/fdk-aac cd fdk-aac autoreconf -fiv ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make -j4 make install安装libmp3lame
cd /home/ffmpeg_sources curl -O -L https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz tar -xvf lame-3.100.tar.gz cd lame-3.100 ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --disable-shared --enable-nasm make -j4 make install安装libopus
cd /home/ffmpeg_sources curl -O -L https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz tar -xvf opus-1.3.1.tar.gz cd opus-1.3.1 ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make -j4 make install安装libvpx
cd /home/ffmpeg_sources git clone https://github.com/webmproject/libvpx.git cd libvpx ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm make -j4 make install下载并编译ffmpeg
cd /home/ffmpeg_sources curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 tar -xvf ffmpeg-snapshot.tar.bz2 cd ffmpeg export PATH="$HOME/bin:$PATH" export PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \ --prefix="$HOME/ffmpeg_build" \ --pkg-config-flags="--static" \ --extra-cflags="-I$HOME/ffmpeg_build/include" \ --extra-ldflags="-L$HOME/ffmpeg_build/lib" \ --extra-libs=-lpthread \ --extra-libs=-lm \ --bindir="$HOME/bin" \ --enable-gpl \ --enable-libfdk_aac \ --enable-libmp3lame \ --enable-libopus \ --enable-libvpx \ --enable-libx264 \ --enable-libx265 \ --enable-nonfree make -j4 make install ##最终编译完安装路劲在/root/bin 下面。上面的配置参数$HOME,为当前用户的根目录,则root账号在root文件夹下面