Asyncio support async/await

Author: akolpakovCreated May 4, 2019Updated May 2, 2026
Labelsenhancement

Now I'm working on Asynchronous application. And using asyncio library which is built in python3. And uses async/await syntax.

Good to have possibility to return ffmpeg process as a coroutine and use it in a asyncio way.

For example:

process = await (
    ffmpeg
    .input('input.mp4')
    .output('pipe:', format='rawvideo', pix_fmt='rgb24')['v']
    .run_asyncio(pipe_stdout=True, quiet=False)
)

while True:
    frame_bytes = await process.stdout.read(video_frame_size)
    if len(frame_bytes) == 0:
        break

await process.wait()

It would be very handy for asynchronous applications.