import cv2 import rich if __name__ == '__main__': videoCapture = cv2.VideoCapture('niuzi.mp4') # 创建一个窗口,并设置大小 cv2.namedWindow('sudemo', cv2.WINDOW_NORMAL) cv2.resizeWindow('sudemo', 800, 600) # 设置窗口的宽度和高度 while True: ret, frame = videoCapture.read() if not ret: rich.print("播放完毕") break else: cv2.imshow('sudemo', frame) if cv2.waitKey(25) & 0xFF == ord('q'): break videoCapture.release() cv2.destroyAllWindows()