1.opencv库简单操作视频
# coding = utf-8
# Getting Started with Videos
import cv2
import numpy as np
# 创建捕获视频对象
cap = cv2.VideoCapture('偶像宣言(第001集)[流畅].mp4')
# if you want to save it, must do these
# fourcc = cv2.VideoWriter_fourcc(*'XVID')
# out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640, 480))
while cap.isOpened():
# 读取每帧,返回读取结果(True or False)和帧对象
ret, frame = cap.read()
# 处理每帧图片
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA)
gray = cv2.flip(gray, 0)
# 展示每帧图片
cv2.imshow('frame', gray)
# out.write(gray)
# 每帧之间的过渡时间
if cv2.waitKey(100) == ord('q'):
break
cap.release()
# out.release()
cv2.destroyAllWindows()