Asyncio support async/await
Created by: akolpakov
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.