From 05a368db9eea6aa585a0bfc0b64bc5feda6d71bf Mon Sep 17 00:00:00 2001 From: Felipe Astroza Date: Tue, 17 Oct 2017 14:03:04 -0300 Subject: [PATCH 1/2] custom stdin support --- ffmpy.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ffmpy.py b/ffmpy.py index 203f486..f21901e 100644 --- a/ffmpy.py +++ b/ffmpy.py @@ -59,7 +59,7 @@ def __init__(self, executable='ffmpeg', global_options=None, inputs=None, output def __repr__(self): return '<{0!r} {1!r}>'.format(self.__class__.__name__, self.cmd) - def run(self, input_data=None, stdout=None, stderr=None): + def run(self, input_data=None, stdin=None, stdout=None, stderr=None): """Execute FFmpeg command line. ``input_data`` can contain input for FFmpeg in case ``pipe`` protocol is used for input. @@ -78,6 +78,7 @@ def run(self, input_data=None, stdout=None, stderr=None): :param str input_data: input data for FFmpeg to deal with (audio, video etc.) as bytes (e.g. the result of reading a file in binary mode) + :param stdin: replace FFmpeg ``stdin`` (default is `None` which means `subprocess.PIPE`) :param stdout: redirect FFmpeg ``stdout`` there (default is `None` which means no redirection) :param stderr: redirect FFmpeg ``stderr`` there (default is `None` which means no @@ -87,10 +88,13 @@ def run(self, input_data=None, stdout=None, stderr=None): :raise: `FFRuntimeError` in case FFmpeg command exits with a non-zero code; `FFExecutableNotFoundError` in case the executable path passed was not valid """ + if input_data != None or stdin == None: + stdin = subprocess.PIPE + try: self.process = subprocess.Popen( self._cmd, - stdin=subprocess.PIPE, + stdin=stdin, stdout=stdout, stderr=stderr ) From 51aecd29a8dfe2e1eaddddead0120d49f6cb1b68 Mon Sep 17 00:00:00 2001 From: Felipe Astroza Date: Tue, 17 Oct 2017 14:49:57 -0300 Subject: [PATCH 2/2] flake8 --- ffmpy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmpy.py b/ffmpy.py index f21901e..1a76359 100644 --- a/ffmpy.py +++ b/ffmpy.py @@ -88,7 +88,7 @@ def run(self, input_data=None, stdin=None, stdout=None, stderr=None): :raise: `FFRuntimeError` in case FFmpeg command exits with a non-zero code; `FFExecutableNotFoundError` in case the executable path passed was not valid """ - if input_data != None or stdin == None: + if input_data is not None or stdin is None: stdin = subprocess.PIPE try: