Table of contents
1--Download FFmpeg
① Download ffmpeg version 5.1
wget http://www.ffmpeg.org/releases/ffmpeg-5.1.tar.gz
② Unzip the downloaded compressed package
tar -zxvf ffmpeg-5.1.tar.gz
2--Compile FFmpeg
① Enter the folder after decompression
cd ffmpeg-5.1
② Installation dependencies
# 安装ffplay需要的依赖
sudo apt-get install libx11-dev xorg-dev libsdl2-2.0 libsdl2-dev
sudo apt install clang libfdk-aac-dev libspeex-dev libx264-dev libx265-dev libnuma-dev
sudo apt install yasm pkg-config libopencore-amrnb-dev libopencore-amrwb-dev
③ compile ffmpeg
# 查看帮助文档确定需要安装的相关参数
./configure --help
./configure --enable-gpl --enable-version3 --enable-nonfree --enable-ffplay --enable-ffprobe --enable-libx264 --enable-libx265 --enable-debug
make
Note: The make step usually takes a long time ;
sudo make install
3--Set environment variables
① View the current path
pwd
② Add the current path to the environment variable
export PATH="$PATH:/home/liujinfu/Downloads/ffmpeg-5.1/ffmpeg"
Note: The above code essentially adds the executable file ffmpeg (green) to the environment variable;
Generally speaking, the step of adding environment variables can be omitted, because in the process of compiling ffmpeg, under normal circumstances, the three executable files ffmpeg, ffplay and ffprobe will be automatically added to the /usr/local/bin directory;
4--Test
① Check the version of ffmpeg
ffmpeg -version
ffplay -version
ffprobe -version
② View ffmpeg help documentation
ffmpeg -h
ffmpeg -h long
ffmpeg -h full
③ Uninstall ffmpeg
# cd ffmpeg-5.1/ 进入ffmpeg源码编译的路径
sudo make uninstall