the following code plays a given video file on a tkinter window:
from tkinter import *
from PIL import ImageTk, Image
import cv2
root = Tk()
main_label = Label(root)
main_label.grid()
# Capture from camera
cap = cv2.VideoCapture("video.mp4")
# function for video streaming
def video_stream():
ret, frame = cap.read()
cv2image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)
img = Image.fromarray(cv2image)
tk_img = ImageTk.PhotoImage(image=img)
main_label.configure(image=tk_img)
main_label.tk_img = tk_img
main_label.after(20, video_stream)
video_stream()
root.mainloop()
my question is how can I resize the video to be played in a 500 by 500 resolution for example?