ffmpeg安装
安装链接:Jetson 环境安装(三):jetson nano配置ffmpeg和nginx(亲测)
安装完以后,在配置文件.zshrc 或者.bashrc中加入ffmpeg的环境变量:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/Your/Path/ffmpeg/lib/
export PATH=/Your/Path/ffmpeg/ffmpeg/bin/:$PATH
export PKG_CONFIG_PATH=/Your/Path/ffmpeg/lib/pkgconfig/
上述步骤都做完以后,检查ffmpeg是否安装成功:
ffmpeg -version
opencv编译
我们这里要用自己下载的ffmpeg源码来对opencv源码进行编译
将源码下载下来之后,创建build文件夹,并进入,打开cmd,输入以下的命名即可
cmake -D WITH_IPP=OFF -D BUILD_opencv_python3=YES -D PYTHON_DEFAULT_EXECUTABLE=/home/lqs/anaconda3/bin/python3.7 -D BUILD_opencv_python3=ON -D BUILD_opencv_python2=OFF -D PYTHON3_EXECUTABLE=/home/lqs/anaconda3/bin/python3 -D PYTHON3_INCLUDE_DIR=/home/lqs/anaconda3/include/python3.7m -D PYTHON3_INCLUDE_PATH=/home/lqs/anaconda3/include/python3.7m -D PYTHON3_LIBRARY=/home/lqs/anaconda3/lib/libpython3.7m.so.1.0 -D PYTHON3_NUMPY_INCLUDE_DIRS=/home/lqs/anaconda3/lib/python3.7/site-packages/numpy/core/include -D PYTHON3_PACKAGES_PATH=/home/lqs/anaconda3/lib/python3.7/site-packages -D HAVE_opencv_python3=ON -D OPENCV_ENABLE_MEMORY_SANITIZER=ON -D WITH_QT=OFF -D ENABLE_CXX11=ON -D WITH_CUDA=OFF -D FFMPEG_INCLUDE_DIR=/usr/local/ffmpeg/include -D FFMPEG_LIB_DIR=/usr/local/ffmpeg/lib -D ENABLE_PRECOMPILED_HEADERS=OFF ..
cp /home/lqs/Downloads/opencv-3.4.0/build/lib/python3/* /home/lqs/anaconda3/lib/python3.7/site-packages/
cmake \
-D WITH_IPP=OFF\
-D PYTHON_DEFAULT_EXECUTABLE=$(python -c "import sys; print(sys.executable)")\
-D BUILD_opencv_python3=ON\
-D BUILD_opencv_python2=ON\
-D BUILD_opencv_java=OFF\
-D PYTHON3_EXECUTABLE=$(which python3)\
-D PYTHON3_INCLUDE_DIR=/home/lqs/anaconda3/include/python3.7m\
-D PYTHON3_INCLUDE_PATH=/home/lqs/anaconda3/include/python3.7m\
-D PYTHON3_LIBRARY=/home/lqs/anaconda3/lib/libpython3.7m.so.1.0\
-D PYTHON3_NUMPY_INCLUDE_DIRS=/home/lqs/anaconda3/lib/python3.7/site-packages/numpy/core/include\
-D PYTHON3_NUMPY_PATH=/home/lqs/anaconda3/lib/python3.7/site-packages\
-D OPENCV_ENABLE_MEMORY_SANITIZER=ON\
-D WITH_QT=OFF\
-D ENABLE_CXX11=ON\
-D WITH_CUDA=OFF\
-D FFMPEG_INCLUDE_DIR=/usr/local/ffmpeg/include\
-D FFMPEG_LIB_DIR=/usr/local/ffmpeg/lib\
-D ENABLE_PRECOMPILED_HE ..
然后在通过
make -j8
如果报错了,则你可以将你修改的源代码的文件,替换了/usr/include/x86_64-linux-gnu下的文件,也就是说直接命令行copy /usr/local/ffmpeg/include下的全部文件 到/usr/include/x86_64-linux-gnu。
安装之后目录介绍:bin 执行文件目录,lib 静态,动态链接库目录,include 编程用到的头文件
卸载opencv
- 找到当初安装opencv建立的build目录,进入目录执行卸载操作
cd cd /home/cheng/somelib/opencv-3.4.10/build/
sudo make uninstall
cd ..
rm -rf build
- 删除相关项
sudo -s
rm -rf /usr/local/include/opencv2
rm -rf /usr/local/include/opencv
rm -rf /usr/include/opencv
rm -rf /usr/include/opencv2
rm -rf /usr/local/share/opencv
rm -rf /usr/local/share/OpenCV
rm -rf /usr/share/opencv
rm -rf /usr/share/OpenCV
rm -rf /usr/local/bin/opencv*
rm -rf /usr/local/lib/libopencv*
- 查找是否还有剩余
cd /usr
find . -name "*opencv*" | xargs sudo rm -rf
- 检查是否删除完
pkg-config --modversion opencv
报错情况
- 1./sbin/ldconfig.real: /usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_ops_train.so.8 不是符号链接
解决办法:建立软链接
sudo ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.0.1 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_train.so.8
sudo ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.0.1 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8
sudo ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.0.1 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8
sudo ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.0.1 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8
sudo ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.0.1 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_train.so.8
sudo ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.0.1 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8
- 2.cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)错误
解决办法:sudo rm -rf /usr/local/lib/libcurl.so.4
ln -s /usr/lib/x86_64-linux-gnu/libcurl.so.4.5.0 /usr/local/lib/libcurl.so.4
- 3 libavcodec/libx264.c:282:9: error: ‘x264_bit_depth’ undeclared (first use in this function); did you mean ‘x264_picture_t’?
解决办法:打开libx264.c,找到相应的代码行,将“x264_bit_depth”改成“X264_BIT_DEPTH”即可