1. System:
2. Install H264
wget https://code.videolan.org/videolan/x264/-/archive/master/x264-master.zip
# 进入文件
cd x264
./configure --enable-static --enable-shared --prefix=/usr/local/x264
make -j4
sudo make install
3. Install ffmpeg
wget https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n4.3.6.zip
cd ffmpeg
./configure --enable-gpl --enable-libx264 --prefix=/usr/local/ffmpeg --enable-shared --enable-ffplay
make -j4
sudo make install
4、opencv
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff5.dev libswscale-dev
https://github.com/opencv/opencv/archive/refs/tags/3.4.16.zip
unzip 3.4.16.zip
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=ON -D CMAKE_INSTALL_PREFIX=/usr/local -DBUILD_TIFF=ON ..
make -j4
make install
4. Test
ffmpeg -i 11_test.wmv -y -qscale 0 -vcodec libx264 test.mp4
5, reference
Ubuntu 20.04 source code compilation and installation of OpenCV 4.7.0