diff --git a/run.py_ b/run.py_ new file mode 100644 index 00000000..df1e51db --- /dev/null +++ b/run.py_ @@ -0,0 +1,29 @@ +@output_operator() +async def run_asyncio( + stream_spec, cmd='ffmpeg', pipe_stdin=False, pipe_stdout=False, pipe_stderr=False, + quiet=False, overwrite_output=False): + """Asynchronously invoke ffmpeg in asyncio sync/await style and return coroutine. + Have the same possibilities as `run_async` call. + Args: + pipe_stdin: if True, connect pipe to subprocess stdin (to be + used with ``pipe:`` ffmpeg inputs). + pipe_stdout: if True, connect pipe to subprocess stdout (to be + used with ``pipe:`` ffmpeg outputs). + pipe_stderr: if True, connect pipe to subprocess stderr. + quiet: shorthand for setting ``capture_stdout`` and + ``capture_stderr``. + Returns: + A Process instance as a coroutine + """ + + args = compile(stream_spec, cmd, overwrite_output=overwrite_output) + stdin_stream = asyncio.subprocess.PIPE if pipe_stdin else None + stdout_stream = asyncio.subprocess.PIPE if pipe_stdout or quiet else None + stderr_stream = asyncio.subprocess.PIPE if pipe_stderr or quiet else None + + return await asyncio.create_subprocess_exec( + *args, + stdin=stdin_stream, + stdout=stdout_stream, + stderr=stderr_stream + )