import cv2
video_caputre = cv2.VideoCapture('source.MOV')
fps = int(video_caputre.get(cv2.CAP_PROP_FPS))
size = int(video_caputre.get(cv2.CAP_PROP_FRAME_WIDTH)), int(video_caputre.get(cv2.CAP_PROP_FRAME_HEIGHT))
print(fps, size)
videoWriter = cv2.VideoWriter('new.avi', cv2.VideoWriter_fourcc('X', 'V', 'I', 'D'), fps, size)
Flag = False
while True:
ret, frame = video_caputre.read()
if ret:
cv2.imshow("new", frame)
if Flag:
videoWriter.write(frame)
key = cv2.waitKey(1)
if key == ord('s'):
Flag = True
elif key == ord('e'):
Flag = False
elif key == ord('q'):
break
else:
print("视频结束")
break
cv2.destroyAllWindows()
videoWriter.release()