用图像生成视频流出现的问题 Failed to load OpenH264 library

1、报以下错误


> 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 @ 00000212dce9a000] Incorrect library version loaded
> Could not open codec 'libopenh264': Unspecified error

解决办法:点进提示的网址https://github.com/cisco/openh264/releases下载openh264-1.8.0-win64.dll 压缩到对应的.py文件目录即可。
2、问题二:可以生成视频文件但是没播放,说文件受损之类的话。
有两种可能:
1、VideoWriter的size与frame不一致,这种情况下保存下来的视频会很小,不到1KB,解决方案是把Size调一致。
2. 视频保存下来也有一定大小但是打不开:
官方文档的教程包括网上大部分教程都是这样创建fourcc的:

fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi',fourcc, fps, size)

然后我的文件就打不开了,后来把’XVID’改成"MJPG"就可以了:


fourcc = cv2.VideoWriter_fourcc(*'MJPG')
out = cv2.VideoWriter('output.avi',fourcc, fps, size)

你可能感兴趣的:(python,机器学习,人工智能)