import ffmpeg import os in_filename = "/home/albmj/media/Cowboy_Bebop.mkv" width=640 height=360 process1 = ( ffmpeg .input(in_filename,re=None,stream_loop="-1") .filter('scale', width, height) .filter('subtitles', in_filename, force_style='Fontsize=120', si='2') .output('pipe:', format='rawvideo', pix_fmt='rgb24') .run_async(pipe_stdout=True,quiet=False) ) fd = os.open("/tmp/video",os.O_RDWR|os.O_CREAT) os.lseek(fd,0,os.SEEK_SET) #fd = os.memfd_create('test_file') print(f'{width}x{height}x3={width*height*3}') print(f'/tmp/video') while True: in_bytes = process1.stdout.read(width * height * 3) if len(in_bytes) != width*height*3: print("wrong size") print(len(in_bytes)) exit(1) os.write(fd, in_bytes) os.lseek(fd, 0, os.SEEK_SET)