Open and show video frames with OpenCv

Here is how to show a video, frame by frame, with opencv.

To install it you have to

pip install opencv-python

The code to open and show video frames

import cv2
import sys

# print(sys.version)

print("Capturing video")
movie = cv2.VideoCapture("full.mp4")
print("Video captured")

opened = movie.isOpened

if not opened:
	print("Stream error")

while opened:
	ret, frame = movie.read()
	if ret == True:
		cv2.imshow("Frame", frame)
		if cv2.waitKey(25) & 0xFF == ord('q'):
			break
	else:
		break

movie.release()

cv2.destroyAllWindows()

The live coding video to show video frames

 


Subscribe to the newsletter for updates
Tkinter templates
My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts