当前位置:   article > 正文

解决python-opencv不能写h264视频_opecn failed[/home/linaro/app/video/advertising_hu

opecn failed[/home/linaro/app/video/advertising_huati.h264] >>>>>>>>>>> *gst

由于opcv和ffmpeg开源许可证不同

fourcc = cv2.VideoWriter.fourcc(*'h264')
video = cv2.VideoWriter(filename, fourcc, 25, (1920,1080))
  • 1
  • 2

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()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/484734
推荐阅读
相关标签
  

闽ICP备14008679号