yum install -y libtheora-devel libvorbis-devel openssl-devel openssl
yum install -y libtool autoconf automake
yum install -y gcc-c++
yum -y install gnutls gnutls-devel lame lame-devel faac faac-devel
git clone git://github.com/mstorsjo/fdk-aac
cd fdk-aac
aclocal;libtoolize --force;autoconf;autoheader;automake
autoreconf -i
./configure
make install
cd ..
#进入https://sourceforge.net/projects/lame/,下载lame-3.100
tar -zxf lame-3.100.tar.gz
cd lame-3.100
./configure
make
make install
cd..
wget https://www.nasm.us/pub/nasm/releasebuilds/2.14/nasm-2.14.tar.gz --no-check-certificate
tar zxvf nasm-2.14.tar.gz
cd nasm-2.14
./configure
make install
cd..
git clone https://code.videolan.org/videolan/x264.git
cd x264
# 如果不将include和lib安装在/usr/local目录,之后运行ffmpeg命令时可能仍然报错误
./configure --prefix=/usr/x264/ --includedir=/usr/local/include --libdir=/usr/local/lib --enable-shared
make install
cd..
#vi /etc/profile
//在/etc/profile文件中加入
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/fontconfig/lib/pkgconfig:$PKG_CONFIG_PATH
保存后执行source /etc/profile
wget https://download.savannah.gnu.org/releases/freetype/freetype-2.9.1.tar.gz --no-check-certificate
tar zxvf freetype-2.9.1.tar.gz
cd freetype-2.9.1/
./configure --prefix=/usr/local/freetype2 --disable-static
make
make install
wget "https://github.com/fribidi/fribidi/releases/download/v1.0.4/fribidi-1.0.4.tar.bz2" --no-check-certificate
tar xf fribidi-1.0.4.tar.bz2
cd fribidi-1.0.4
./configure --prefix=/usr/local/fribidi --enable-shared &&
make install
wget http://mirrors.ustc.edu.cn/gnu/gperf/gperf-3.1.tar.gz
tar zxvf gperf-3.1.tar.gz
cd gperf-3.1
./configure
make
make install
为防止出现找不到 libfreetype 的错误,首先修改 PKG_CONFIG_PATH 环境变量:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/fontconfig/lib/pkgconfig:$PKG_CONFIG_PATH
wget "https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.0.tar.gz" --no-check-certificate
yum -y install libuuid-devel
yum -y install libxml2
yum -y install libxml2-devel
#对于centos8
yum install freetype-devel fribidi-devel diffutils -y
cd fontconfig-2.13.0
./configure --prefix=/usr/local/fontconfig --enable-shared --enable-libxml2
make
make install
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/fontconfig/lib/pkgconfig:$PKG_CONFIG_PATH
wget https://github.com/libass/libass/releases/download/0.14.0/libass-0.14.0.tar.xz --no-check-certificate
tar xvf libass-0.14.0.tar.xz
cd libass-0.14.0
./configure --prefix=/usr/local/ --disable-static
make
make install
wget http://ffmpeg.org/releases/ffmpeg-4.2.2.tar.bz2
tar -jxvf ffmpeg-4.2.2.tar.bz2
cd ffmpeg-4.2.2
./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-version3 --enable-pthreads --enable-shared --enable-libmp3lame --enable-libx264 --enable-pic --enable-libfdk-aac --enable-openssl --enable-libass --enable-nonfree --pkgconfigdir=/usr/local/lib/pkgconfig
make -j24
make install
# vi /etc/profile
// 在profile文件中加入
PATH=$PATH:/usr/local/ffmpeg/bin
export PATH
保存后执行source /etc/profile
运行:$ ffmpeg -v
ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory
执行vi /etc/ld.so.conf
加入
/usr/local/ffmpeg/lib
/usr/lib
/usr/lib64
/usr/local/lib
执行:ldconfig
$ ffmpeg -y -i 4.wmv -vcodec libx264 -qscale 0 -f mp4 video.mp4
版权声明:本文为vah101原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。