三分钟带你用三分钟带你用python写一个自己的播放器写一个自己的播放器
步骤:步骤:
1.用1.用OpenCV读取视频流;读取视频流;
2.用2.用cv2.show()把读取的帧显示出来即可。把读取的帧显示出来即可。
看代码:
#coding:utf-8
import os
import cv2
def video_reader(video_path):
video = cv2.VideoCapture(video_path)
succ, frame = video.read()
height, width, _ = frame.shape
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
out = cv2.VideoWriter('result.avi', fourcc, 10.0, (width, height))
while succ:
succ, frame = video.read()
if not succ:
break
out.write(frame)
cv2.imshow("test_video", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cv2.destroyAllWindows()
video.release()
out.release()
if __name__ == "__main__":
video_path = "test.mp4"
video_reader(video_path)
参考:https://blog.csdn.net/Guo_Python/article/details/105821786
CV-deeplearning
原创文章 19获赞 26访问量 2607
关注
私信
展开阅读全文
作者:CV-deeplearning