我尝试阅读视频,翻转帧然后保存它,但输出视频窗口显示它已损坏并且无法播放。
import cv2 as cv
cap = cv.VideoCapture('wtf.avi')
fourcc = cv.VideoWriter_fourcc(*'DIVX')
out= cv.VideoWriter('output.avi', fourcc, 20.0, (640,480))
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
frame = cv.flip(frame, 0)
# write the flipped frame
out.write(frame)
cv.imshow('frame', frame)
if cv.waitKey(35) & 0xFF == ord('q'):
break
else:
break
# Release everything if job is finished
cap.release()
out.release()
cv.destroyAllWindows()