#coding: utf-8
import tkinter as tk, threading
import imageio
from PIL import Image, ImageTk
video_name = "test.mp4" #ここにヴィデオ・ファイル名を書く
video = imageio.get_reader(video_name)
gen = video.iter_data()
def stream(label):
def showlabel():
global count
try:
image=gen.__next__()
except:
return
frame_image = ImageTk.PhotoImage(Image.fromarray(image))
label.config(image=frame_image)
label.image = frame_image
label.after(14, showlabel) #フレーム・レイトの調整
showlabel()
if __name__ == "__main__":
root = tk.Tk()
root.title('TKinterでヴィデオを見る')
my_label = tk.Label(root)
my_label.pack()
thread = threading.Thread(target=stream, args=(my_label,))
thread.daemon = 1
thread.start()
root.mainloop()