赞
踩
由于opcv和ffmpeg开源许可证不同
fourcc = cv2.VideoWriter.fourcc(*'h264')
video = cv2.VideoWriter(filename, fourcc, 25, (1920,1080))
opencv写入视频会报如下错误
[ERROR:16@10.044] global cap_ffmpeg_impl.hpp:3018 open Could not find encoder for codec_id=27, error: Encoder not found
[ERROR:16@10.044] global cap_ffmpeg_impl.hpp:3093 open VIDEOIO/FFMPEG: Failed to initialize VideoWriter
解决方案:
1.自行编译opcv(嫌麻烦没试过)
2.使用skvideo库
writer = skvideo.io.FFmpegWriter(path, outputdict={'-vcodec': 'libx264', '-pix_fmt': 'yuv420p'})
for frame in frames:
#writer.writeFrame(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
# cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) bgr图像转为rgb
writer.writeFrame(frame)
writer.close()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。