描述:
import cv2
vc = cv2.VideoCapture('./src.webm')
videoWriter = cv2.VideoWriter('./dst.avi', cv2.VideoWriter_fourcc(*'MJPG'), 30, (640,480))
rval=vc.isOpened()
c = 0
while rval:
rval, frame = vc.read()
# 每10幀取一張圖片放入視頻中
if (c % 10 == 0):
# 如果保存成圖片就使用下面這句代碼
# cv2.imwrite('YOUR_PATH'+str(c) + '.jpg', frame)
# 對原圖像壓縮一下
img = cv2.resize(frame,(640,480))
videoWriter.write(img)
c = c + 1
vc.release()
videoWriter.release()