import time import subprocess from PIL import Image, ImageDraw, ImageFont fnt = ImageFont.truetype('/usr/share/fonts/noto/NotoSans-Regular.ttf', 15) my_ffmpeg_process = subprocess.Popen("ffmpeg -y -i pipe: -r 30 -pix_fmt yuv420p video.webm".split(), stdin=subprocess.PIPE) for i in range(100): img = Image.new('RGB', (130, 30), color=(73, 109, 137)) d = ImageDraw.Draw(img) d.text((10, 10), str(i), font=fnt, fill=(255, 255, 0)) img.save(my_ffmpeg_process.stdin, format='png') print(i) for i in range(100): img = Image.new('RGB', (130, 30), color=(73, 109, 137)) d = ImageDraw.Draw(img) d.text((10, 10), str("Thx u ali1234"), font=fnt, fill=(255, 255, 0)) img.save(my_ffmpeg_process.stdin, format='png') print(i) #time.sleep(1)