【待解决】Could not find encoder for codec_id=27,opencv-python 保存H264格式的错误记录
代码
cv2.VideoWriter(vide_save_path, cv2.VideoWriter_fourcc(*'avc1'), fps, (width, height))
报错
[ERROR:0@39.657] global cap_ffmpeg_impl.hpp:3130 open Could not find encoder for codec_id=27, error: Encoder not found
[ERROR:0@39.657] global cap_ffmpeg_impl.hpp:3208 open VIDEOIO/FFMPEG: Failed to initialize VideoWriter
环境
Ubuntu 20.04.5 LTS
python version is 3.9
---
opencv-contrib-python 4.9.0.80
opencv-python 4.9.0.80
尝试了非常多的方法(github issue、stackoverflow、各种博客等),都没有效果
可能可以解决的
OpenCV4 安装编译以支持h264 h265 x264 cuda - 简书 (jianshu.com)
手动编译对应版本的OpenCV: Install OpenCV-Python in Ubuntu