import time from datetime import datetime from threading import Thread from PIL import Image from PIL import ImageDraw, ImageFont from VideoFile import VideoFile class StreamMerger(Thread): img = None def run(self) -> None: video = VideoFile("yiv3.webm") video2 = VideoFile("supernatural.webm") video.open() video2.open() start_time = time.time() while True: img = Image.new('RGB', (1920, 1080), color='black') if video.frame is not None: img.paste(video.frame) if video2.frame is not None: img.paste(video2.frame, (0, 600)) fnt = ImageFont.truetype("antonio.ttf", 40) d = ImageDraw.Draw(img) d.text((0, 1000), str(int(time.time() - start_time)), font=fnt) self.img = img time.sleep(1.0 / 1000.0)