Python播放本地视频代码
时间: 2023-03-13 10:52:28 浏览: 119
基于Python实现播放本地视频文件
5星 · 资源好评率100%
可以使用 Python 的 OpenCV 库来解码、播放本地视频,代码参考如下:import cv2# Get the video
video = cv2.VideoCapture("video.mp4")# Check if camera opened successfully
if (video.isOpened()== False):
print("Error opening video stream or file")# Read until video is completed
while(video.isOpened()):
# Capture frame-by-frame
ret, frame = video.read()
if ret == True:
# Display the resulting frame
cv2.imshow('Frame',frame)
# Press q to quit
if cv2.waitKey(25) & 0xFF == ord('q'):
break
# Break the loop
else:
break# When everything done, release the video capture object
video.release()# Closes all the frames
cv2.destroyAllWindows()
阅读全文