import cv2
创建一个VideoWriter对象,指定视频编解码器、输出文件路径、帧率等
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter('output.mp4', fourcc, 30.0, (640, 480))
假设我们有一些视频帧数据
frame = cv2.imread('frame.jpg')
将帧写入视频文件
out.write(frame)
释放VideoWriter对象
out.release()