1 opencv-python保存视频时出现Failed to load OpenH264 library: openh264-1.8.0-win64.dll,Please check environment and/or download library错误

今天在使用opencv-python库保存视频时出现Failed to load OpenH264 library: openh264-1.8.0-win64.dll,Please check environment and/or download library错误。主要是将输入视频resize后保存为新的视频,我根据输入视频的fourcc视频格式作为输出视频的fourcc视频格式,然后保存视频就出现了上述错误。

Python – opencv-python保存视频时出现Failed to load OpenH264 library: openh264-1.8.0-win64.dll错误-StubbornHuang Blog

然后检查了以下输入视频的格式为h264的格式,而我又没有额外下载h264库,所以出现了无法加载h264编码库的错误,所以我们只需要从h264的Github仓库下载对应的库,然后将该库放在对应的运行脚本同级目录下即可。

我们首先根据报错信息,缺少的是openh264-1.8.0-win64.dll,我们首先到h264的Release的页面下载对应的dll,下载地址为:https://github.com/cisco/openh264/releases

Python – opencv-python保存视频时出现Failed to load OpenH264 library: openh264-1.8.0-win64.dll错误-StubbornHuang Blog

我们首先下载包含openh264-1.8.0-win64.dll的压缩包,然后进行解压缩,假设我当前的进行视频resize的脚本video_resize.py在目录:E:/test/video_process下,那么我们也需要将下载的openh264-1.8.0-win64.dll也放到目录:E:/test/video_process下,重新运行脚本即可。