三分钟带你用python写一个自己的播放器

Rasine ·
更新时间:2024-09-21
· 506 次阅读

步骤: 1.用OpenCV读取视频流; 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



用python 三分 Python

需要 登录 后方可回复, 如果你还没有账号请 注册新账号