编译ffmpeg命令如下:
1.安装yasm
powershell
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xvzf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make && make install
2.安装nasm(2.13以上版本)
powershell
wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2
tar xvf nasm-2.14.02.tar.bz2
cd nasm-2.14.02
./configure
make && make install
3.安装其他依赖
powershell
apt install cmake -y
4.编译x264(只编译静态库)
x264下载地址:
http://ftp.videolan.org/pub/videolan/x264/snapshots/
powershell
tar xvf x264-snapshot-20191024-2245-stable.tar.bz2
cd x264-snapshot-20191024-2245-stable
./configure --enable-static --prefix=../x264 --enable-pic
make -j16
make install
5.编译x265(只编译静态库)
x265下载地址:
http://ftp.videolan.org/pub/videolan/x265/
powershell
tar xvf x265_3.2.tar.gz
cd x265_3.2/build/linux/
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="../../../x265" -DENABLE_SHARED:bool=off ../../source
make -j16
make install
6.编译ffmpeg
powershell
tar xvf ffmpeg-4.1.3.tar.bz2
cd ffmpeg-4.1.3
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:../x264/lib/pkgconfig:../x265/lib/pkgconfig
./configure --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libx264 --enable-libx265 --prefix=../ffmpeg
make -j32
make install
注:如果报错找不到x264或x265,ubunut下多半是因为没有安装pkg-config。安装命令为:apt install pkg-config
7、配置ffmpeg环境变量
powershell
gedit ~/.bashrc
export FFmpeg_PATH=/usr/ffmpeg4.1/ffmpeg
需要让os能够找到 ffmpeg ffprobe等命令
powershell
export PATH=$FFmpeg_PATH/bin:$PATH
需要提供路径, 让ffmpeg ffprobe等命令找到需要的依赖
powershell
export LD_LIBRARY_PATH=$FFmpeg_PATH/lib:$LD_LIBRARY_PATH