python opencv 写视频

参数设置: 

        out_file = "cug.avi"
        x_shape = int(player.get(cv2.CAP_PROP_FRAME_WIDTH))
        y_shape = int(player.get(cv2.CAP_PROP_FRAME_HEIGHT))
        four_cc = cv2.VideoWriter_fourcc(*"MJPG")
        out = cv2.VideoWriter(out_file, four_cc, 20, (x_shape, y_shape))

循环逐帧写入文件:

out.write(frame)  # 写入

记得释放资源: 

out.release()

你可能感兴趣的:(pytorch,opencv)