Tuesday, December 24, 2024

Display .mp4 using Python

import cv2


video = cv2.VideoCapture('Video.mp4')  # Replace with your video file path

while True:

    ret, frame = video.read()  # Read each frame

    if not ret:

        break  # Exit if no more frames

    cv2.imshow('Video', frame)  # Display frame in a window

    if cv2.waitKey(25) & 0xFF == ord('q'):    # Press 'q' to exit

        break

video.release()  # Release video object

cv2.destroyAllWindows()  # Close all windows

No comments:

Post a Comment