Jul-23-2024, 04:18 PM
Hi, I've been trying to simply play a video in python using the python GUI. So far, it has been working as intended and the video has been playing fine with no interuptions. However, there seem to be some issues:
- No sound (no module is installed)
- Tiny window showing the video
- The video is sped up
- If I try to exit the program while the video is playing, it crashes
*Yes, I do know the reason why the sound isnt playing but I have tried my best to install different modules in order to gain sound and none have worked.
Below is the code:
I hope that I manage to fix these problems I am experiencing with your sincere help and advice. I thank you for your time, patience and kindness!

- No sound (no module is installed)
- Tiny window showing the video
- The video is sped up
- If I try to exit the program while the video is playing, it crashes
*Yes, I do know the reason why the sound isnt playing but I have tried my best to install different modules in order to gain sound and none have worked.
Below is the code:
I hope that I manage to fix these problems I am experiencing with your sincere help and advice. I thank you for your time, patience and kindness!


import tkinter as tk from tkinter import Label from PIL import Image, ImageTk import imageio import threading class VideoPlayer: def __init__(self, root, video_path): self.root = root self.video_path = video_path self.video_label = Label(root) self.video_label.pack() self.video = imageio.get_reader(r"C:\Users\RPC-K\Downloads\windows 95 maze screensaver 022 speedrun [WORLD RECORD].mp4") self.play_video = True self.thread = threading.Thread(target=self.update, args=()) self.thread.start() def update(self): for frame in self.video.iter_data(): if not self.play_video: break image = Image.fromarray(frame) image = ImageTk.PhotoImage(image) self.video_label.config(image=image) self.video_label.image = image self.root.update() self.video.close() def stop(self): self.play_video = False self.thread.join() def on_close(): player.stop() root.destroy() if __name__ == "__main__": root = tk.Tk() root.title("Video Player") video_path = 'path_to_your_video.mp4' player = VideoPlayer(root, video_path) root.protocol("WM_DELETE_WINDOW", on_close) root.mainloop()