報如下錯誤:
Could not find libavformat with pkg-config. Could not find libavcodec with pkg-config. Could not find libavdevice with pkg-config. Could not find libavutil with pkg-config. Could not find libavfilter with pkg-config. Could not find libswscale with pkg-config. Could not find libswresample with pkg-config.
可以對應安裝apt-get install libavformat-dev 等庫
如果編譯錯誤,可以嘗試:
root用戶下安裝步驟:
安裝ffmpeg
mkdir ffmpeg
wget http://www.ffmpeg.org/releases/ffmpeg-4.1.3.tar.gz tar -zxvf ffmpeg-4.1.3.tar.gz cd ffmpeg-4.1.3 ./configure --enable-shared --enable-pic --enable-static --disable-x86asm --prefix=/root/yuefu/ffmpeg #其中/root/yuefu/ffmpeg換成自己要安裝的路徑 make -j32 make install
vi /etc/ld.so.conf.d/ffmpeg.conf
在末尾添加一行,路徑換成自己的
/root/yuefu/ffmpeg/lib
使配置生效
ldconfig
配置profile系統文件
vim /etc/profile
在末尾添加一行
export PATH=$PATH:/root/yuefu/ffmpeg/bin
使配置文件生效
source /etc/profile
使opencv能找到ffmpeg
pip3 install opencv-python
cp /root/yuefu/ffmpeg/lib/pkgconfig/* /usr/share/pkgconfig
安裝pyav
git clone https://gitee.com/mirrors/PyAV.git cd PyAV/ python3 setup.py build --ffmpeg-dir=/root/yuefu/ffmpeg python3 setup.py install
點擊復制
測試pyav安裝是否成功
cd ..
python3
import av
注意:不要再PyAv目錄下測試,否則報錯
ModuleNotFoundError: No module named 'av._core'