cv2改变视频帧率

import cv2

cap = cv2.VideoCapture(“MOT16-06-results.mp4”)
width = 640
ret = cap.set(3, width)
height = 480
fourcc = cv2.VideoWriter_fourcc(*‘mp4v’) # XVID

out = cv2.VideoWriter(‘out.mp4’, fourcc, 19.12, (width, height))
i = 0
while cap.isOpened():
ret, frame = cap.read()
if ret is True:
frame = cv2.resize(frame, (640, 480))
out.write(frame)
cv2.imshow(‘frame’, frame)
if i == 900:
break
i += 1
else:
break
key = cv2.waitKey(1)
if key == ord(‘q’):
break
cap.release()
out.release()
cv2.destroyAllWindows()

你可能感兴趣的:(python,视频处理)