Tkinter inserting video into window [duplicate] Tkinter inserting video into window [duplicate] tkinter tkinter

Tkinter inserting video into window [duplicate]


Here's one way to do it. This will continuously update the labels image to be the frames of the video specified. You'll have to handle sound if you want that too. This should get you started.

import tkinter as tk, threadingimport imageiofrom PIL import Image, ImageTkvideo_name = "test.mkv" #This is your video file pathvideo = imageio.get_reader(video_name)def stream(label):    for image in video.iter_data():        frame_image = ImageTk.PhotoImage(Image.fromarray(image))        label.config(image=frame_image)        label.image = frame_imageif __name__ == "__main__":    root = tk.Tk()    my_label = tk.Label(root)    my_label.pack()    thread = threading.Thread(target=stream, args=(my_label,))    thread.daemon = 1    thread.start()    root.mainloop()