代码:
from cv2 import cv2
#视频读写
videoCapture = cv2.VideoCapture('C:/Users/admin/Desktop/test/video/1.mp4')
#获取视频帧率
fps = videoCapture.get(cv2.CAP_PROP_FPS)
#获取视频宽和高
Size=(int(videoCapture.get(cv2.CAP_PROP_FRAME_WIDTH)),int(videoCapture.get(cv2.CAP_ PROP_FRAME_HEIGHT)))
videoWriter=cv2.VideoWriter('C:/Users/admin/Desktop/test/video/2.mp4',cv2.VideoWriter_ fourcc('X','V','I','D'),fps,size)
success,frame = videoCapture.read()
while success:
videoWriter.write(frame)
success,frame = videoCapture.read()
其中:
cv2.VideoWriter_ fourcc('I','4','2','0'):未压缩YUV颜色编码,4:2:0色度采样,具有很好兼容性,但会产生较大文件;
cv2.VideoWriter_ fourcc('P','I','M','1'):MPEG-1编码;
cv2.VideoWriter_ fourcc('X','V','I','D'):MPEG-4编码;
cv2.VideoWriter_ fourcc('T','H','E','O'):Ogg Vorbis,ogv格式编码;
cv2.VideoWriter_ fourcc('F','L','V','1'):flash视频。
27万+

被折叠的 条评论
为什么被折叠?



