错误信息:
OpenCV: FFMPEG: tag 0x34363248/'H264' is not supported with codec id 27 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
Failed to load OpenH264 library: openh264-1.8.0-win64.dll
Please check environment and/or download library: https://github.com/cisco/openh264/releases
[libopenh264 @ 00000181eb518cc0] Incorrect library version loaded
[ERROR:0@1.590] global /build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp (2822) open Could not open codec libopenh264, error: Unspecified error
[ERROR:0@1.590] global /build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp (2839) open VIDEOIO/FFMPEG: Failed to initialize VideoWriter
主要是应为原生安装的OpenCV是没有H264编码器的,需要自行配置
下载地址:
这里配置的是anaconda下python的虚拟环境
选择好自己的系统对应的库文件,我是windows,下载的是openh264-1.8.0-win64.dll
将压缩包解压
将该文件复制到虚拟环境中python工程根目录下,如下图我的环境名为yolo_cuda,将dll文件复制到此路径下即可