视频获取
通过request
import requests
url = "https://flv.bn.netease.com/videolib3/1703/29/qozNg4588/SD/qozNg4588-mobile.mp4"
res = requests.get(url,stream=True)
with open('a.mp4','wb') as f:
f.write(res.content)
f.close
print(res.status_code)
print(res)
视频处理
将视频切成图片
使用pip install opencv-python
import cv2
#可以直接输入url地址也可以先使用request请求存到本地读取本地地址
mp4 = cv2.VideoCapture("https://flv.bn.netease.com/videolib3/1703/29/qozNg4588/SD/qozNg4588-mobile.mp4")
# mp4 = cv2.VideoCapture(a.mp4)
is_opened = mp4.isOpened() # 判断是否打开
print(is_opened)
fps = mp4.get(cv2.CAP_PROP_FPS) # 获取视频的帧率
print(fps)
widght = mp4.get(cv2.CAP_PROP_FRAME_WIDTH) # 获取视频的宽度
height = mp4.get(cv2.CAP_PROP_FRAME_HEIGHT) # 获取视频的高度
print(str(widght) + "x" + str(height))
i = 0
count = 0
whi