insert video in tkinter

Solutions on MaxInterview for insert video in tkinter by the best coders in the world

showing results for - "insert video in tkinter"
Silvia
12 Aug 2017
1import tkinter as tk, threading
2import imageio
3from PIL import Image, ImageTk
4
5video_name = "test.mkv" #This is your video file path
6video = imageio.get_reader(video_name)
7
8def stream(label):
9
10    for image in video.iter_data():
11        frame_image = ImageTk.PhotoImage(Image.fromarray(image))
12        label.config(image=frame_image)
13        label.image = frame_image
14
15if __name__ == "__main__":
16
17    root = tk.Tk()
18    my_label = tk.Label(root)
19    my_label.pack()
20    thread = threading.Thread(target=stream, args=(my_label,))
21    thread.daemon = 1
22    thread.start()
23    root.mainloop()